summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgad <gad@FreeBSD.org>2002-06-04 01:16:13 +0000
committergad <gad@FreeBSD.org>2002-06-04 01:16:13 +0000
commit48a6ff1d630a9951d161fe61a64d81fda4f0a991 (patch)
treedf31c1023991d0f423e1ca3932e63ce32a0dc0c9
parent9b39ed7b9416390758870edd85ae19dbee651312 (diff)
downloadFreeBSD-src-48a6ff1d630a9951d161fe61a64d81fda4f0a991.zip
FreeBSD-src-48a6ff1d630a9951d161fe61a64d81fda4f0a991.tar.gz
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
-rw-r--r--usr.sbin/lpr/lpd/printjob.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.sbin/lpr/lpd/printjob.c b/usr.sbin/lpr/lpd/printjob.c
index cacd93c..ef18701 100644
--- a/usr.sbin/lpr/lpd/printjob.c
+++ b/usr.sbin/lpr/lpd/printjob.c
@@ -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 @@ start:
exit(2);
}
(void) close(fi);
+ wstatus_set = 0;
if (child < 0)
retcode = 100;
else {
@@ -819,8 +820,10 @@ start:
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 @@ start:
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);
OpenPOWER on IntegriCloud