Lines 43-48
Link Here
|
43 |
extern void *(*currState)(); |
43 |
extern void *(*currState)(); |
44 |
extern int execOnStop; |
44 |
extern int execOnStop; |
45 |
|
45 |
|
|
|
46 |
jmp_buf jmpTerm; |
47 |
|
46 |
/*****************************************************************************/ |
48 |
/*****************************************************************************/ |
47 |
void killPid(sig) |
49 |
void killPid(sig) |
48 |
int sig; |
50 |
int sig; |
Lines 127-142
Link Here
|
127 |
} |
129 |
} |
128 |
logger(LOG_ERR, "terminating on signal %d",sig); |
130 |
logger(LOG_ERR, "terminating on signal %d",sig); |
129 |
} |
131 |
} |
130 |
if (!Persistent || sig != SIGTERM) |
132 |
if (sig == SIGTERM) siglongjmp(jmpTerm, 1); |
131 |
{ |
133 |
if (!Persistent) dhcpStop(); |
132 |
/* Disable execing programs on SIGTERM as if any services get restarted then |
|
|
133 |
* they get hung and are un-useable even though they do get restarted and |
134 |
* apparently without error. Fix this, as it as a dhcpcd error! */ |
135 |
if (sig == SIGTERM) execOnStop = 0; |
136 |
dhcpStop(); |
137 |
} |
138 |
deletePidFile(); |
134 |
deletePidFile(); |
139 |
exit(sig); |
135 |
|
|
|
136 |
/* Exit with 0 if we were told to quit, otherwise the SIG code */ |
137 |
if (sig == SIGQUIT || sig == SIGINT || sig == SIGHUP) |
138 |
exit(0); |
139 |
else |
140 |
exit(sig); |
140 |
} |
141 |
} |
141 |
/*****************************************************************************/ |
142 |
/*****************************************************************************/ |
142 |
void signalSetup() |
143 |
void signalSetup() |
Lines 148-151
Link Here
|
148 |
action.sa_flags = 0; |
149 |
action.sa_flags = 0; |
149 |
for (i=1;i<16;i++) sigaction(i,&action,NULL); |
150 |
for (i=1;i<16;i++) sigaction(i,&action,NULL); |
150 |
sigaction(SIGCHLD,&action,NULL); |
151 |
sigaction(SIGCHLD,&action,NULL); |
|
|
152 |
|
153 |
/* We do this so that we can call external programs safely from a SIGTERM */ |
154 |
if ( sigsetjmp(jmpTerm, 1) ) { |
155 |
if (!Persistent) dhcpStop(); |
156 |
deletePidFile(); |
157 |
exit(0); |
158 |
} |
151 |
} |
159 |
} |