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:
parent
494273bead
commit
cb263c3594
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=97788
@ -58,8 +58,8 @@ void
|
|||||||
instructions()
|
instructions()
|
||||||
{
|
{
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
union wait pstat;
|
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
int pstat;
|
||||||
char *pager, *path;
|
char *pager, *path;
|
||||||
|
|
||||||
if (stat(_PATH_INSTR, &sb)) {
|
if (stat(_PATH_INSTR, &sb)) {
|
||||||
@ -84,7 +84,7 @@ instructions()
|
|||||||
do {
|
do {
|
||||||
pid = waitpid(pid, (int *)&pstat, 0);
|
pid = waitpid(pid, (int *)&pstat, 0);
|
||||||
} while (pid == -1 && errno == EINTR);
|
} while (pid == -1 && errno == EINTR);
|
||||||
if (pid == -1 || pstat.w_status)
|
if (pid == -1 || WEXITSTATUS(pstat) || WTERMSIG(pstat))
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,8 +126,8 @@ choke()
|
|||||||
void
|
void
|
||||||
child()
|
child()
|
||||||
{
|
{
|
||||||
union wait status;
|
pid_t pid;
|
||||||
int pid;
|
int status;
|
||||||
|
|
||||||
(void) signal(SIGCHLD, SIG_IGN);
|
(void) signal(SIGCHLD, SIG_IGN);
|
||||||
do {
|
do {
|
||||||
|
@ -131,8 +131,7 @@ int
|
|||||||
raw_pclose(FILE *iop)
|
raw_pclose(FILE *iop)
|
||||||
{
|
{
|
||||||
register struct pid *cur, *last;
|
register struct pid *cur, *last;
|
||||||
int omask;
|
int omask, pstat;
|
||||||
union wait pstat;
|
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
(void)fclose(iop);
|
(void)fclose(iop);
|
||||||
@ -158,5 +157,5 @@ raw_pclose(FILE *iop)
|
|||||||
last->next = cur->next;
|
last->next = cur->next;
|
||||||
free(cur);
|
free(cur);
|
||||||
|
|
||||||
return (pid == -1 ? -1 : pstat.w_status);
|
return (pid == -1 ? -1 : pstat);
|
||||||
}
|
}
|
||||||
|
@ -468,16 +468,16 @@ writeroob(int signo __unused)
|
|||||||
void
|
void
|
||||||
catch_child(int signo __unused)
|
catch_child(int signo __unused)
|
||||||
{
|
{
|
||||||
union wait status;
|
pid_t pid;
|
||||||
int pid;
|
int status;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
pid = wait3((int *)&status, WNOHANG|WUNTRACED, NULL);
|
pid = wait3(&status, WNOHANG|WUNTRACED, NULL);
|
||||||
if (pid == 0)
|
if (pid == 0)
|
||||||
return;
|
return;
|
||||||
/* if the child (reader) dies, just quit */
|
/* if the child (reader) dies, just quit */
|
||||||
if (pid < 0 || (pid == child && !WIFSTOPPED(status)))
|
if (pid < 0 || (pid == child && !WIFSTOPPED(status)))
|
||||||
done((int)(status.w_termsig | status.w_retcode));
|
done(WTERMSIG(status) | WEXITSTATUS(status));
|
||||||
}
|
}
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
@ -209,11 +209,11 @@ usage()
|
|||||||
void
|
void
|
||||||
finish()
|
finish()
|
||||||
{
|
{
|
||||||
int die, e, pid;
|
pid_t pid;
|
||||||
union wait status;
|
int die, e, status;
|
||||||
|
|
||||||
die = e = 0;
|
die = e = 0;
|
||||||
while ((pid = wait3((int *)&status, WNOHANG, 0)) > 0)
|
while ((pid = wait3(&status, WNOHANG, 0)) > 0)
|
||||||
if (pid == child) {
|
if (pid == child) {
|
||||||
die = 1;
|
die = 1;
|
||||||
if (WIFEXITED(status))
|
if (WIFEXITED(status))
|
||||||
|
@ -48,10 +48,9 @@ static char rcsid[] =
|
|||||||
void
|
void
|
||||||
wwchild()
|
wwchild()
|
||||||
{
|
{
|
||||||
int olderrno;
|
|
||||||
register struct ww **wp;
|
register struct ww **wp;
|
||||||
union wait w;
|
pid_t pid;
|
||||||
int pid;
|
int olderrno, w;
|
||||||
char collected = 0;
|
char collected = 0;
|
||||||
|
|
||||||
olderrno = errno;
|
olderrno = errno;
|
||||||
|
Loading…
Reference in New Issue
Block a user