From: Adam Dickmeiss Date: Sun, 18 Jan 2004 02:28:42 +0000 (+0000) Subject: Fixed PID file so it is generated after fork (-r & -D) X-Git-Tag: YAZ.2.0.10~10 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=83ac63cea12d7b176008739ac5fdafd01f628bef;p=yaz-moved-to-github.git Fixed PID file so it is generated after fork (-r & -D) --- diff --git a/src/statserv.c b/src/statserv.c index dd52b6a..ebd0b70 100644 --- a/src/statserv.c +++ b/src/statserv.c @@ -1,12 +1,11 @@ /* * Copyright (c) 1995-2004, Index Data * See the file LICENSE for details. - * Sebastian Hammer, Adam Dickmeiss * * NT threaded server code by * Chas Woodfield, Fretwell Downing Informatics. * - * $Id: statserv.c,v 1.4 2004-01-17 01:20:13 adam Exp $ + * $Id: statserv.c,v 1.5 2004-01-18 02:28:42 adam Exp $ */ #include @@ -743,6 +742,27 @@ int statserv_start(int argc, char **argv) inetd_connection(control_block.default_proto); else { + if (control_block.background) + { + switch (fork()) + { + case 0: + break; + case -1: + return 1; + default: + _exit(0); + } + + if (setsid() < 0) + return 1; + + close(0); + close(1); + close(2); + open("/dev/null",O_RDWR); + dup(0); dup(0); + } if (!pListener && *control_block.default_listen) add_listener(control_block.default_listen, control_block.default_proto); @@ -792,27 +812,6 @@ int statserv_start(int argc, char **argv) exit(1); } } - if (!control_block.inetd && control_block.background) - { - switch (fork()) - { - case 0: - break; - case -1: - return 1; - default: - _exit(0); - } - - if (setsid() < 0) - return 1; - - close(0); - close(1); - close(2); - open("/dev/null",O_RDWR); - dup(0); dup(0); - } /* UNIX */ #endif if ((pListener == NULL) && *control_block.default_listen)