diff -u dhcpcd-2.0.5/src/client.c dhcpcd-2.0.6/src/client.c --- dhcpcd-2.0.5/src/client.c 2006-04-27 22:18:29.000000000 +0100 +++ dhcpcd-2.0.6/src/client.c 2006-06-05 11:47:11.000000000 +0100 @@ -99,8 +91,6 @@ int deleteDhcpCache(); void execute_on_change(char *prm); -int execOnStop = 1; - int dhcpSocket; int udpFooSocket; int prev_ip_addr; @@ -105,7 +105,7 @@ dhcpOptions DhcpOptions; dhcpInterface DhcpIface; udpipMessage UdpIpMsgSend,UdpIpMsgRecv; -jmp_buf env; +sigjmp_buf env; unsigned char ClientHwAddr[ETH_ALEN]; const struct ip *ipSend=(struct ip *)((struct udpiphdr *)UdpIpMsgSend.udpipmsg)->ip; @@ -1307,8 +1308,6 @@ if ( ntp_renamed ) rename(ntp_file_sv, ntp_file); - if ( ! execOnStop ) return &dhcpStart; - if ( ! stat("/sbin/resolvconf", &buf) ) { #ifdef EMBED diff -u dhcpcd-2.0.5/src/signals.c dhcpcd-2.0.6/src/signals.c --- dhcpcd-2.0.5/src/signals.c 2006-04-27 22:18:29.000000000 +0100 +++ dhcpcd-2.0.6/src/signals.c 2006-06-05 11:47:11.000000000 +0100 @@ -39,10 +39,12 @@ extern char *IfNameExt; extern char *ConfigDir; extern int Persistent; -extern jmp_buf env; +extern sigjmp_buf env; extern void *(*currState)(); extern int execOnStop; +sigjmp_buf jmpTerm; + /*****************************************************************************/ void killPid(sig) int sig; @@ -127,16 +129,15 @@ } logger(LOG_ERR, "terminating on signal %d",sig); } - if (!Persistent || sig != SIGTERM) - { - /* Disable execing programs on SIGTERM as if any services get restarted then - * they get hung and are un-useable even though they do get restarted and - * apparently without error. Fix this, as it as a dhcpcd error! */ - if (sig == SIGTERM) execOnStop = 0; - dhcpStop(); - } + if (sig == SIGTERM) siglongjmp(jmpTerm, 1); + if (!Persistent) dhcpStop(); deletePidFile(); - exit(sig); + + /* Exit with 0 if we were told to quit, otherwise the SIG code */ + if (sig == SIGQUIT || sig == SIGINT || sig == SIGHUP) + exit(0); + else + exit(sig); } /*****************************************************************************/ void signalSetup() @@ -148,4 +149,11 @@ action.sa_flags = 0; for (i=1;i<16;i++) sigaction(i,&action,NULL); sigaction(SIGCHLD,&action,NULL); + + /* We do this so that we can call external programs safely from a SIGTERM */ + if ( sigsetjmp(jmpTerm, 0xffff) ) { + if (!Persistent) dhcpStop(); + deletePidFile(); + exit(0); + } }