deal with wait3() returning -1. be careful on malloc failures. sync with kame

This commit is contained in:
itojun 2001-11-21 06:52:35 +00:00
parent a3c923dc72
commit d1fee0dd15
3 changed files with 15 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: faithd.c,v 1.20 2001/09/05 01:22:24 itojun Exp $ */
/* $NetBSD: faithd.c,v 1.21 2001/11/21 06:52:35 itojun Exp $ */
/* $KAME: faithd.c,v 1.40 2001/07/02 14:36:48 itojun Exp $ */
/*
@ -301,9 +301,13 @@ daemon_main(int argc, char **argv)
exit_stderr("too many arguments");
serverpath = malloc(strlen(argv[NUMPRG]) + 1);
if (!serverpath)
exit_stderr("not enough core");
strcpy(serverpath, argv[NUMPRG]);
for (i = 0; i < serverargc; i++) {
serverarg[i] = malloc(strlen(argv[i + NUMARG]) + 1);
if (!serverarg[i])
exit_stderr("not enough core");
strcpy(serverarg[i], argv[i + NUMARG]);
}
serverarg[i] = NULL;
@ -770,9 +774,10 @@ sig_child(int sig)
int status;
pid_t pid;
pid = wait3(&status, WNOHANG, (struct rusage *)0);
if (pid && WEXITSTATUS(status))
syslog(LOG_WARNING, "child %d exit status 0x%x", pid, status);
while ((pid = wait3(&status, WNOHANG, (struct rusage *)0)) > 0)
if (WEXITSTATUS(status))
syslog(LOG_WARNING, "child %d exit status 0x%x",
pid, status);
}
void

View File

@ -1,4 +1,4 @@
/* $NetBSD: prefix.c,v 1.2 2001/09/05 01:22:24 itojun Exp $ */
/* $NetBSD: prefix.c,v 1.3 2001/11/21 06:52:35 itojun Exp $ */
/* $KAME: prefix.c,v 1.9 2001/07/02 14:36:49 itojun Exp $ */
/*
@ -67,12 +67,14 @@ prefix_set(s, prefix, slash)
struct prefix *prefix;
int slash;
{
char *p, *q, *r;
char *p = NULL, *q, *r;
struct addrinfo hints, *res = NULL;
int max;
char *a;
p = strdup(s);
if (!p)
goto fail;
q = strchr(p, '/');
if (q) {
if (!slash)

View File

@ -1,4 +1,4 @@
/* $NetBSD: tcp.c,v 1.5 2001/09/05 01:22:24 itojun Exp $ */
/* $NetBSD: tcp.c,v 1.6 2001/11/21 06:52:35 itojun Exp $ */
/* $KAME: tcp.c,v 1.6 2001/07/02 14:36:49 itojun Exp $ */
/*
@ -92,7 +92,7 @@ sig_child(int sig)
pid_t pid;
pid = wait3(&status, WNOHANG, (struct rusage *)0);
if (pid && WEXITSTATUS(status))
if (pid > 0 && WEXITSTATUS(status))
syslog(LOG_WARNING, "child %d exit status 0x%x", pid, status);
exit_success("terminate connection due to child termination");
}