diff -Nru ppp-2.4.4.orig/pppd/main.c ppp-2.4.4/pppd/main.c --- ppp-2.4.4.orig/pppd/main.c 2006-11-03 11:28:38.000000000 +0200 +++ ppp-2.4.4/pppd/main.c 2006-11-03 11:30:49.080255750 +0200 @@ -248,6 +248,7 @@ static void forget_child __P((int pid, int status)); static int reap_kids __P((void)); static void childwait_end __P((void *)); +static void wait_children __P((void)); #ifdef USE_TDB static void update_db_entry __P((void)); @@ -579,25 +580,11 @@ if (!persist) break; } + + wait_children(); } - /* Wait for scripts to finish */ - reap_kids(); - if (n_children > 0) { - if (child_wait > 0) - TIMEOUT(childwait_end, NULL, child_wait); - if (debug) { - struct subprocess *chp; - dbglog("Waiting for %d child processes...", n_children); - for (chp = children; chp != NULL; chp = chp->next) - dbglog(" script %s, pid %d", chp->prog, chp->pid); - } - while (n_children > 0 && !childwait_done) { - handle_events(); - if (kill_link && !childwait_done) - childwait_end(NULL); - } - } + wait_children(); die(status); return 0; @@ -1776,6 +1763,36 @@ } /* + * wait_children - wait for scripts to finish. + * if child_wait is 0, wait indefinitely. + * else, kill'em all at the end of timeout + */ +static void +wait_children() +{ + /* Wait for scripts to finish */ + reap_kids(); + if (n_children > 0) { + childwait_done = 0; + if (child_wait > 0) + TIMEOUT(childwait_end, NULL, child_wait); + if (debug) { + struct subprocess *chp; + dbglog("Waiting for %d child processes...", n_children); + for (chp = children; chp != NULL; chp = chp->next) + dbglog(" script %s, pid %d", chp->prog, chp->pid); + } + while (n_children > 0 && !childwait_done) { + handle_events(); + if (asked_to_quit && !childwait_done) + childwait_end(NULL); + } + if (child_wait > 0) + UNTIMEOUT(childwait_end, NULL); + } +} + +/* * childwait_end - we got fed up waiting for the child processes to * exit, send them all a SIGTERM. */