Run as daemon under windoze

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@13169 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2002-03-20 12:59:45 +00:00
parent e1ade6ed23
commit ff4d7e7461
2 changed files with 30 additions and 6 deletions

View file

@ -4,6 +4,7 @@
contains more bytes than unicode string has characters.
* Tools/gdomap.c: Suppress unnecessary warnings except under debug.
Implement spawning to run as daemon under windoze.
* Toolds/gdnc.m: Run as daemon under windoze.
* Source/GSTcpPort.m: Fix to stop multiple servers trying to use
the same port under windoze.
* Source/WindowsFileHandle.m: Fix to stop multiple servers trying to use

View file

@ -24,6 +24,10 @@
#include <stdio.h>
#include <unistd.h>
#ifdef __MINGW__
#include "process.h"
#endif
#include "gdnc.h"
@interface GDNCNotification : NSObject
@ -461,7 +465,7 @@
NSMutableArray *byName;
NSMutableArray *byObject;
unsigned pos;
GDNCNotification *notification;
GDNCNotification *notification = nil;
byName = [observersForNames objectForKey: notificationName];
byObject = [observersForObjects objectForKey: notificationObject];
@ -472,8 +476,8 @@
{
GDNCObserver *obs = [byName objectAtIndex: pos - 1];
if (obs->notificationObject == nil ||
[obs->notificationObject isEqual: notificationObject])
if (obs->notificationObject == nil
|| [obs->notificationObject isEqual: notificationObject])
{
[observers addObject: obs];
}
@ -482,8 +486,8 @@
{
GDNCObserver *obs = [byObject objectAtIndex: pos - 1];
if (obs->notificationName == nil ||
[obs->notificationName isEqual: notificationName])
if (obs->notificationName == nil
|| [obs->notificationName isEqual: notificationName])
{
if ([observers indexOfObjectIdenticalTo: obs] == NSNotFound)
{
@ -792,13 +796,32 @@ main(int argc, char** argv, char** env)
#ifdef GS_PASS_ARGUMENTS
[NSProcessInfo initializeWithArguments:argv count:argc environment:env];
#endif
if (argc > 1 && strcmp(argv[argc-1], "-f") == 0)
{
shouldFork = NO;
}
str = [[NSUserDefaults standardUserDefaults] stringForKey: @"debug"];
if (str != nil && [str caseInsensitiveCompare: @"yes"] == NSOrderedSame)
{
shouldFork = NO;
}
RELEASE(pool);
#ifndef __MINGW__ /* Don't fork on Win32 */
#ifdef __MINGW__
if (shouldFork)
{
char **a = malloc((argc+2) * sizeof(char*));
memcpy(a, argv, argc*sizeof(char*));
a[argc] = "-f";
a[argc+1] = 0;
if (_spawnv(_P_NOWAIT, argv[0], a) == -1)
{
fprintf(stderr, "gdnc - spawn failed - bye.\n");
exit(1);
}
exit(0);
}
#else
if (shouldFork)
{
switch (fork())