Avoid checking WIFEXITED and WTERMSIG in some error situations where the

value in wstatus is not related to the process that we care about.

MFC after:	2 weeks
This commit is contained in:
Garance A Drosehn 2002-06-04 01:16:13 +00:00
parent cb263c3594
commit 4a13c4d9ee
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=97789

View File

@ -602,7 +602,7 @@ print(struct printer *pp, int format, char *file)
int fi, fo;
FILE *fp;
char *av[15], buf[BUFSIZ];
int pid, p[2], retcode, stopped, wstatus;
int pid, p[2], retcode, stopped, wstatus, wstatus_set;
struct stat stb;
if (lstat(file, &stb) < 0 || (fi = open(file, O_RDONLY)) < 0) {
@ -810,6 +810,7 @@ print(struct printer *pp, int format, char *file)
exit(2);
}
(void) close(fi);
wstatus_set = 0;
if (child < 0)
retcode = 100;
else {
@ -819,8 +820,10 @@ print(struct printer *pp, int format, char *file)
retcode = 100;
syslog(LOG_WARNING, "%s: after execv(%s), wait() returned: %m",
pp->printer, prog);
} else
} else {
wstatus_set = 1;
retcode = WEXITSTATUS(wstatus);
}
}
child = 0;
prchild = 0;
@ -839,7 +842,7 @@ print(struct printer *pp, int format, char *file)
fclose(fp);
}
if (!WIFEXITED(wstatus)) {
if (wstatus_set && !WIFEXITED(wstatus)) {
syslog(LOG_WARNING, "%s: filter '%c' terminated (termsig=%d)",
pp->printer, format, WTERMSIG(wstatus));
return(ERROR);