Skip to content

Commit

Permalink
Fix pkg hanging if some process spawn by the script remains
Browse files Browse the repository at this point in the history
running after script itself exits.

Submitted by:	sobomax
  • Loading branch information
bapt committed Apr 29, 2020
1 parent 6b89ff0 commit 08b81c0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion libpkg/scripts.c
Expand Up @@ -245,12 +245,19 @@ pkg_script_run(struct pkg * const pkg, pkg_script type, bool upgrade)

f = fdopen(pfd.fd, "r");
for (;;) {
if (poll(&pfd, 1, -1) == -1) {
int pres = poll(&pfd, 1, -1);
if (pres == -1) {
if (errno == EINTR)
continue;
else
goto cleanup;
}
if (pres == 0) {
if (waitpid(pid, NULL, WNOHANG | WNOWAIT) > 0) {
break;
}
continue;
}
if (pfd.revents & (POLLERR|POLLHUP))
break;
if (getline(&line, &linecap, f) > 0)
Expand Down

0 comments on commit 08b81c0

Please sign in to comment.