diff --git a/usr.sbin/lpr/lpd/lpd.c b/usr.sbin/lpr/lpd/lpd.c index c5ac5ecac190..47b3e1f53e5d 100644 --- a/usr.sbin/lpr/lpd/lpd.c +++ b/usr.sbin/lpr/lpd/lpd.c @@ -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) ; } diff --git a/usr.sbin/lpr/lpd/printjob.c b/usr.sbin/lpr/lpd/printjob.c index 876584bfc5a8..cacd93c81d81 100644 --- a/usr.sbin/lpr/lpd/printjob.c +++ b/usr.sbin/lpr/lpd/printjob.c @@ -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 @@ start: } (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 @@ start: 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 @@ start: 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 @@ return_sfres: 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); } /*