X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fmain.c;h=fe34cff76bf1da04cfab96850d17082c69dfd8de;hb=f2af1c05596be799c0c0ec1e451b8b0ae5ddabc6;hp=b5702f2b07ffabe274661511c67d9ffb4cfda7ee;hpb=ba63d2751b8143c0c9d602e9790eda8e178966ce;p=ppp.git diff --git a/pppd/main.c b/pppd/main.c index b5702f2..fe34cff 100644 --- a/pppd/main.c +++ b/pppd/main.c @@ -66,7 +66,7 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#define RCSID "$Id: main.c,v 1.150 2005/03/21 09:20:16 paulus Exp $" +#define RCSID "$Id: main.c,v 1.152 2005/08/25 23:59:34 paulus Exp $" #include #include @@ -534,6 +534,7 @@ main(argc, argv) script_unsetenv("BYTES_RCVD"); lcp_open(0); /* Start protocol */ + start_link(0); while (phase != PHASE_DEAD) { handle_events(); get_input(); @@ -1661,7 +1662,7 @@ device_script(program, in, out, dont_wait) /* * run-program - execute a program with given arguments, - * but don't wait for it. + * but don't wait for it unless wait is non-zero. * If the program can't be executed, logs an error unless * must_exist is 0 and the program file doesn't exist. * Returns -1 if it couldn't fork, 0 if the file doesn't exist @@ -1670,14 +1671,15 @@ device_script(program, in, out, dont_wait) * reap_kids) iff the return value is > 0. */ pid_t -run_program(prog, args, must_exist, done, arg) +run_program(prog, args, must_exist, done, arg, wait) char *prog; char **args; int must_exist; void (*done) __P((void *)); void *arg; + int wait; { - int pid; + int pid, status; struct stat sbuf; /* @@ -1703,6 +1705,14 @@ run_program(prog, args, must_exist, done, arg) if (debug) dbglog("Script %s started (pid %d)", prog, pid); record_child(pid, prog, done, arg); + if (wait) { + while (waitpid(pid, &status, 0) < 0) { + if (errno == EINTR) + continue; + fatal("error waiting for script %s: %m", prog); + } + reap_kids(); + } return pid; }