un as daemon more tidily.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@13615 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2002-05-10 06:59:50 +00:00
parent d4b549943d
commit c9aa89e621
2 changed files with 28 additions and 0 deletions

View file

@ -1,3 +1,8 @@
2002-05-10 Richard Frith-Macdonald <rfm@gnu.org>
* Tools/gdnc.m: Make gdnc log to syslog by default, and close
stdin, stdout, stderr to run as daemon.
2002-05-09 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSHTTPURLHandle.m: Insert port information to URL passed

View file

@ -792,6 +792,7 @@ main(int argc, char** argv, char** env)
GDNCServer *server;
NSString *str;
BOOL shouldFork = YES;
BOOL debugging = NO;
CREATE_AUTORELEASE_POOL(pool);
#ifdef GS_PASS_ARGUMENTS
@ -805,6 +806,7 @@ main(int argc, char** argv, char** env)
if (str != nil && [str caseInsensitiveCompare: @"yes"] == NSOrderedSame)
{
shouldFork = NO;
debugging = YES;
}
RELEASE(pool);
#ifdef __MINGW__
@ -850,7 +852,28 @@ main(int argc, char** argv, char** env)
{
CREATE_AUTORELEASE_POOL(pool);
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
/*
* Make gdnc logging go to syslog unless overridden by user.
*/
[defs registerDefaults: [NSDictionary dictionaryWithObjectsAndKeys:
@"YES", @"GSLogSyslog", nil]];
server = [GDNCServer new];
/*
* Close standard input, output, and error to run as daemon.
*/
[[NSFileHandle fileHandleWithStandardInput] closeFile];
[[NSFileHandle fileHandleWithStandardOutput] closeFile];
#ifndef __MINGW__
if (debugging == NO)
{
[[NSFileHandle fileHandleWithStandardError] closeFile];
}
#endif
RELEASE(pool);
}