It is possible for WIFSTOPPED to be true even if waitpid() is not

given WUNTRACED if the child is ptraced.  Don't exit the waitpid()
loop if WIFSTOPPED is true, just in case.
This commit is contained in:
Todd C. Miller
2015-10-02 11:24:01 -06:00
parent 3f883a80a5
commit 5ad68edd65
3 changed files with 26 additions and 9 deletions

View File

@@ -591,9 +591,13 @@ send_mail(const char *fmt, ...)
break;
default:
/* Parent. */
do {
for (;;) {
rv = waitpid(pid, &status, 0);
} while (rv == -1 && errno == EINTR);
if (rv == -1 && errno != EINTR)
break;
if (rv != -1 && !WIFSTOPPED(status))
break;
}
return true; /* not debug */
}
@@ -732,9 +736,13 @@ send_mail(const char *fmt, ...)
fputs("\n\n", mail);
fclose(mail);
do {
rv = waitpid(pid, &status, 0);
} while (rv == -1 && errno == EINTR);
for (;;) {
rv = waitpid(pid, &status, 0);
if (rv == -1 && errno != EINTR)
break;
if (rv != -1 && !WIFSTOPPED(status))
break;
}
sudo_debug_exit(__func__, __FILE__, __LINE__, sudo_debug_subsys);
_exit(0);
}