Stop using the depreciated 'union wait' definitions, moving to a more

standard handling of wait()-related routines.

Submitted by:	mike
MFC after:	2 weeks
This commit is contained in:
Garance A Drosehn 2002-06-03 20:47:01 +00:00
parent ee3cbef6be
commit 0760287064
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=97781
2 changed files with 25 additions and 26 deletions

View File

@ -428,9 +428,9 @@ main(int argc, char **argv)
static void
reapchild(int signo __unused)
{
union wait status;
int status;
while (wait3((int *)&status, WNOHANG, 0) > 0)
while (wait3(&status, WNOHANG, 0) > 0)
;
}

View File

@ -602,8 +602,7 @@ print(struct printer *pp, int format, char *file)
int fi, fo;
FILE *fp;
char *av[15], buf[BUFSIZ];
int pid, p[2], stopped;
union wait status;
int pid, p[2], retcode, stopped, wstatus;
struct stat stb;
if (lstat(file, &stb) < 0 || (fi = open(file, O_RDONLY)) < 0) {
@ -779,18 +778,17 @@ print(struct printer *pp, int format, char *file)
if (ofilter > 0) { /* stop output filter */
write(ofd, "\031\1", 2);
while ((pid =
wait3((int *)&status, WUNTRACED, 0)) > 0 && pid != ofilter)
wait3(&wstatus, WUNTRACED, 0)) > 0 && pid != ofilter)
;
if (pid < 0)
syslog(LOG_WARNING, "%s: after stopping 'of', wait3() returned: %m",
pp->printer);
else if (status.w_stopval != WSTOPPED) {
else if (!WIFSTOPPED(wstatus)) {
(void) close(fi);
syslog(LOG_WARNING,
"%s: output filter died "
"(pid=%d retcode=%d termsig=%d)",
pp->printer, ofilter, status.w_retcode,
status.w_termsig);
syslog(LOG_WARNING, "%s: output filter died "
"(pid=%d retcode=%d termsig=%d)",
pp->printer, ofilter, WEXITSTATUS(wstatus),
WTERMSIG(wstatus));
return(REPRINT);
}
stopped++;
@ -813,15 +811,16 @@ print(struct printer *pp, int format, char *file)
}
(void) close(fi);
if (child < 0)
status.w_retcode = 100;
retcode = 100;
else {
while ((pid = wait((int *)&status)) > 0 && pid != child)
while ((pid = wait(&wstatus)) > 0 && pid != child)
;
if (pid < 0) {
status.w_retcode = 100;
retcode = 100;
syslog(LOG_WARNING, "%s: after execv(%s), wait() returned: %m",
pp->printer, prog);
}
} else
retcode = WEXITSTATUS(wstatus);
}
child = 0;
prchild = 0;
@ -840,12 +839,12 @@ print(struct printer *pp, int format, char *file)
fclose(fp);
}
if (!WIFEXITED(status)) {
if (!WIFEXITED(wstatus)) {
syslog(LOG_WARNING, "%s: filter '%c' terminated (termsig=%d)",
pp->printer, format, status.w_termsig);
pp->printer, format, WTERMSIG(wstatus));
return(ERROR);
}
switch (status.w_retcode) {
switch (retcode) {
case 0:
pp->tof = 1;
return(OK);
@ -855,7 +854,7 @@ print(struct printer *pp, int format, char *file)
return(ERROR);
default:
syslog(LOG_WARNING, "%s: filter '%c' exited (retcode=%d)",
pp->printer, format, status.w_retcode);
pp->printer, format, retcode);
return(FILTERERR);
}
}
@ -1211,9 +1210,8 @@ sendfile(struct printer *pp, int type, char *file, char format, int copyreq)
static int
execfilter(struct printer *pp, char *f_cmd, char *f_av[], int infd, int outfd)
{
int errfd, fpid, wpid;
int errfd, fpid, retcode, wpid, wstatus;
FILE *errfp;
union wait status; /* XXX */
char buf[BUFSIZ], *slash;
fpid = dofork(pp, DORETURN);
@ -1224,17 +1222,18 @@ execfilter(struct printer *pp, char *f_cmd, char *f_av[], int infd, int outfd)
* the child process which reads the input stream.
*/
if (fpid < 0)
status.w_retcode = 100;
retcode = 100;
else {
while ((wpid = wait((int *)&status)) > 0 &&
while ((wpid = wait(&wstatus)) > 0 &&
wpid != fpid)
;
if (wpid < 0) {
status.w_retcode = 100;
retcode = 100;
syslog(LOG_WARNING,
"%s: after execv(%s), wait() returned: %m",
pp->printer, f_cmd);
}
} else
retcode = WEXITSTATUS(wstatus);
}
/*
@ -1248,7 +1247,7 @@ execfilter(struct printer *pp, char *f_cmd, char *f_av[], int infd, int outfd)
fclose(errfp);
}
return (status.w_retcode);
return (retcode);
}
/*