diff options
-rw-r--r-- | initscripts.spec | 3 | ||||
-rw-r--r-- | src/ppp-watch.c | 22 |
2 files changed, 24 insertions, 1 deletions
diff --git a/initscripts.spec b/initscripts.spec index 4ae4422e..8afca639 100644 --- a/initscripts.spec +++ b/initscripts.spec @@ -195,6 +195,9 @@ rm -rf $RPM_BUILD_ROOT %ghost %attr(0664,root,utmp) /var/run/utmp %changelog +* Thu Sep 23 1999 Michael K. Johnson <johnsonm@redhat.com> +- ppp-watch now always kills pppd pgrp to make sure dialers are dead + * Tue Sep 21 1999 Bill Nottingham <notting@redhat.com> - add a DEFRAG_IPV4 option diff --git a/src/ppp-watch.c b/src/ppp-watch.c index 5a0e7054..dc0454ef 100644 --- a/src/ppp-watch.c +++ b/src/ppp-watch.c @@ -211,6 +211,13 @@ fork_exec(int wait, char *path, char *arg1, char *arg2, char *arg3) if (!(child = fork())) { /* child */ + + if (!wait) { + /* make sure that pppd is in its own process group */ + setsid(); + setpgid(0, 0); + } + execl(path, path, arg1, arg2, arg3, NULL); perror(path); _exit (1); @@ -444,7 +451,10 @@ main(int argc, char **argv) { physicalDevice = pppLogicalToPhysical(&pppdPid, device); if (physicalDevice) { free(physicalDevice); physicalDevice = NULL; } kill(pppdPid, sendsig); - if (sendsig == SIGKILL) cleanExit(32); + if (sendsig == SIGKILL) { + kill(-pppdPid, sendsig); + cleanExit(32); + } } if (theSighup) { theSighup = 0; @@ -484,6 +494,16 @@ main(int argc, char **argv) { waited = wait3(&status, 0, NULL); if (waited < 0) continue; + /* now, we need to kill any children of pppd still in pppd's + * process group, in case they are hanging around. + * pppd is dead (we just waited for it) but there is no + * guarantee that its children are dead, and they will + * hold the modem if we do not get rid of them. + * We have kept the old pid/pgrp around in pppdPid. + */ + kill(-pppdPid, SIGKILL); + pppdPid = 0; + if (!WIFEXITED(status)) cleanExit(29); if (dieing) cleanExit(WEXITSTATUS(status)); |