Use POSIX macros for wait(2)-style status information instead of the

deprecated 4.2/4.3BSD wait union.  Fix some nearby pid_t/int
confusion.
This commit is contained in:
Mike Barcroft 2002-06-03 23:13:11 +00:00
parent 494273bead
commit cb263c3594
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=97788
6 changed files with 15 additions and 17 deletions

View File

@ -58,8 +58,8 @@ void
instructions()
{
struct stat sb;
union wait pstat;
pid_t pid;
int pstat;
char *pager, *path;
if (stat(_PATH_INSTR, &sb)) {
@ -84,7 +84,7 @@ instructions()
do {
pid = waitpid(pid, (int *)&pstat, 0);
} while (pid == -1 && errno == EINTR);
if (pid == -1 || pstat.w_status)
if (pid == -1 || WEXITSTATUS(pstat) || WTERMSIG(pstat))
exit(1);
}
}

View File

@ -126,8 +126,8 @@ choke()
void
child()
{
union wait status;
int pid;
pid_t pid;
int status;
(void) signal(SIGCHLD, SIG_IGN);
do {

View File

@ -131,8 +131,7 @@ int
raw_pclose(FILE *iop)
{
register struct pid *cur, *last;
int omask;
union wait pstat;
int omask, pstat;
pid_t pid;
(void)fclose(iop);
@ -158,5 +157,5 @@ raw_pclose(FILE *iop)
last->next = cur->next;
free(cur);
return (pid == -1 ? -1 : pstat.w_status);
return (pid == -1 ? -1 : pstat);
}

View File

@ -468,16 +468,16 @@ writeroob(int signo __unused)
void
catch_child(int signo __unused)
{
union wait status;
int pid;
pid_t pid;
int status;
for (;;) {
pid = wait3((int *)&status, WNOHANG|WUNTRACED, NULL);
pid = wait3(&status, WNOHANG|WUNTRACED, NULL);
if (pid == 0)
return;
/* if the child (reader) dies, just quit */
if (pid < 0 || (pid == child && !WIFSTOPPED(status)))
done((int)(status.w_termsig | status.w_retcode));
done(WTERMSIG(status) | WEXITSTATUS(status));
}
/* NOTREACHED */
}

View File

@ -209,11 +209,11 @@ usage()
void
finish()
{
int die, e, pid;
union wait status;
pid_t pid;
int die, e, status;
die = e = 0;
while ((pid = wait3((int *)&status, WNOHANG, 0)) > 0)
while ((pid = wait3(&status, WNOHANG, 0)) > 0)
if (pid == child) {
die = 1;
if (WIFEXITED(status))

View File

@ -48,10 +48,9 @@ static char rcsid[] =
void
wwchild()
{
int olderrno;
register struct ww **wp;
union wait w;
int pid;
pid_t pid;
int olderrno, w;
char collected = 0;
olderrno = errno;