Only call reap_kids if we have seen a SIGCHLD.
-static char rcsid[] = "$Id: main.c,v 1.67 1999/03/25 01:30:32 paulus Exp $";
+static char rcsid[] = "$Id: main.c,v 1.68 1999/03/30 04:22:57 paulus Exp $";
#endif
#include <stdio.h>
#endif
#include <stdio.h>
u_char inpacket_buf[PPP_MRU+PPP_HDRLEN]; /* buffer for incoming packet */
static int n_children; /* # child processes still running */
u_char inpacket_buf[PPP_MRU+PPP_HDRLEN]; /* buffer for incoming packet */
static int n_children; /* # child processes still running */
+static int got_sigchld; /* set if we have received a SIGCHLD */
static int locked; /* lock() has succeeded */
static int locked; /* lock() has succeeded */
}
if (get_loop_output())
break;
}
if (get_loop_output())
break;
+ if (got_sigchld)
+ reap_kids(0);
}
remove_fd(fd_loop);
if (kill_link && !persist)
}
remove_fd(fd_loop);
if (kill_link && !persist)
- reap_kids(0); /* Don't leave dead kids lying around */
+ if (got_sigchld)
+ reap_kids(0); /* Don't leave dead kids lying around */
kill_link = 0;
phase = PHASE_DORMANT; /* allow signal to end holdoff */
}
kill_link = 0;
phase = PHASE_DORMANT; /* allow signal to end holdoff */
}
+ if (got_sigchld)
+ reap_kids(0);
} while (phase == PHASE_HOLDOFF);
if (!persist)
break;
} while (phase == PHASE_HOLDOFF);
if (!persist)
break;
/*
* chld - Catch SIGCHLD signal.
/*
* chld - Catch SIGCHLD signal.
- * Calls reap_kids to get status for any dead kids.
+ * Sets a flag so we will call reap_kids in the mainline.
*/
static void
chld(sig)
int sig;
{
*/
static void
chld(sig)
int sig;
{
if (waiting)
siglongjmp(sigjmp, 1);
}
if (waiting)
siglongjmp(sigjmp, 1);
}
if (out == 0)
out = dup(out);
dup2(in, 0);
if (out == 0)
out = dup(out);
dup2(in, 0);
close(in);
}
if (out != 1) {
dup2(out, 1);
close(in);
}
if (out != 1) {
dup2(out, 1);
+ if (out > 2)
+ close(out);
}
if (real_ttyfd > 2)
close(real_ttyfd);
}
if (real_ttyfd > 2)
close(real_ttyfd);
int pid, status;
struct subprocess *chp, **prevp;
int pid, status;
struct subprocess *chp, **prevp;
if (n_children == 0)
return;
while ((pid = waitpid(-1, &status, (waitfor? 0: WNOHANG))) != -1
if (n_children == 0)
return;
while ((pid = waitpid(-1, &status, (waitfor? 0: WNOHANG))) != -1