- 1 -> EXIT_FAILURE

- preallocate child struct, since the signal handler can be called before
  wait_child, and we cannot allocate a child struct there. there is a signal
  race still here if the program exits and the signal handler is called before
  we allocate the struct.
This commit is contained in:
christos 2010-01-12 14:43:31 +00:00
parent 3708b81bde
commit 533d2abbab
1 changed files with 6 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: popen.c,v 1.25 2009/04/10 13:08:25 christos Exp $ */
/* $NetBSD: popen.c,v 1.26 2010/01/12 14:43:31 christos Exp $ */
/*
* Copyright (c) 1980, 1993
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)popen.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: popen.c,v 1.25 2009/04/10 13:08:25 christos Exp $");
__RCSID("$NetBSD: popen.c,v 1.26 2010/01/12 14:43:31 christos Exp $");
#endif
#endif /* not lint */
@ -67,6 +67,7 @@ struct child {
struct child *link;
};
static struct child *child, *child_freelist = NULL;
static struct child *findchild(pid_t, int);
#if 0 /* XXX - debugging stuff. This should go away eventually! */
@ -104,7 +105,7 @@ unregister_file(FILE *fp)
(void)free(p);
return;
}
errx(1, "Invalid file pointer");
errx(EXIT_FAILURE, "Invalid file pointer");
}
PUBLIC void
@ -220,6 +221,7 @@ start_commandv(const char *cmd, sigset_t *nset, int infd, int outfd,
warn("%s", argv[0]);
_exit(1);
}
(void)findchild(pid, 0);
return pid;
}
@ -348,7 +350,7 @@ file_pid(FILE *fp)
for (p = fp_head; p; p = p->link)
if (p->fp == fp)
return p->pid;
errx(1, "Invalid file pointer");
errx(EXIT_FAILURE, "Invalid file pointer");
/*NOTREACHED*/
}