X-Git-Url: https://git.librecmc.org/?p=oweals%2Ftinc.git;a=blobdiff_plain;f=src%2Fprocess.c;h=5aaf573f2d20c8e177052076a61ba2a7689b16be;hp=1319c0c0b90881f0aa6188f64705efaa58f4667e;hb=1eedf54681d4556c6874f7baee8e810cab867756;hpb=0806605ce383b7e89fa26eda56f8a5f3bbed9dd3 diff --git a/src/process.c b/src/process.c index 1319c0c..5aaf573 100644 --- a/src/process.c +++ b/src/process.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: process.c,v 1.1.2.14 2000/11/24 23:13:05 guus Exp $ + $Id: process.c,v 1.1.2.15 2000/11/25 13:33:33 guus Exp $ */ #include "config.h" @@ -150,12 +150,23 @@ int detach(void) cp setup_signals(); + /* First check if we can open a fresh new pidfile */ + if(write_pidfile()) return -1; + /* If we succeeded in doing that, detach */ + if(do_detach) - if(daemon(0, 0) < 0) - return -1; + { + if(daemon(0, 0) < 0) + return -1; + + /* Now UPDATE the pid in the pidfile, because we changed it... */ + + if(!write_pid(pidfilename)) + return 1; + } openlog(identname, LOG_CONS | LOG_PID, LOG_DAEMON); @@ -177,11 +188,8 @@ cp void _execute_script(const char *name) __attribute__ ((noreturn)); void _execute_script(const char *name) { - int error = 0; char *scriptname; char *s; - int fd; - cp if(netname) {