From 00ab926033bd7b156376d4c6554e7b346a581ef5 Mon Sep 17 00:00:00 2001 From: Richard Frith-Macdonald Date: Fri, 23 Jun 2017 14:13:54 +0100 Subject: [PATCH] Move startup audit log earlier so it should be at the start of the log file --- EcProcess.m | 53 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/EcProcess.m b/EcProcess.m index 0ce1827..b65b764 100644 --- a/EcProcess.m +++ b/EcProcess.m @@ -2425,8 +2425,6 @@ NSLog(@"Ignored attempt to set timer interval to %g ... using 10.0", interval); NSRunLoop *loop; NSDate *future; - [self cmdAudit: @"Starting `%@'", [self cmdName]]; - /* Called to permit subclasses to initialise before entering run loop. */ [self ecAwaken]; @@ -4325,6 +4323,12 @@ With two parameters ('maximum' and a number),\n\ [self setCmdInterval: [cmdDefs floatForKey: @"CmdInterval"]]; } + /* Log that we are starting up, after the config required for logging + * is in place, but before we have updated config from the Command + * server (since updating config may generater log files). + */ + [self cmdAudit: @"Starting `%@'", [self cmdName]]; + if (YES == [self cmdIsClient] && nil == [self cmdNewServer]) { NSLog(@"Giving up - unable to contact '%@' server on '%@'", @@ -4335,29 +4339,32 @@ With two parameters ('maximum' and a number),\n\ } [ecLock unlock]; - /* Put self in background. - */ - if ([cmdDefs boolForKey: @"Daemon"] == YES) + if (self != nil) { - int pid = fork(); + /* Put self in background. + */ + if ([cmdDefs boolForKey: @"Daemon"] == YES) + { + int pid = fork(); - if (pid == 0) - { - cmdFlagDaemon = YES; - setpgid(0, getpid()); - } - else - { - if (pid < 0) - { - printf("Failed fork to run as daemon.\r\n"); - } - else - { - printf("Process backgrounded (running as daemon)\r\n"); - } - exit(0); - } + if (pid == 0) + { + cmdFlagDaemon = YES; + setpgid(0, getpid()); + } + else + { + if (pid < 0) + { + printf("Failed fork to run as daemon.\r\n"); + } + else + { + printf("Process backgrounded (running as daemon)\r\n"); + } + exit(0); + } + } } return self;