Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Fix pkg hanging if some process spawn by the script remains running after script itself exits.
Baptiste Daroussin committed 6 years ago
commit a4c28a60425254a80085a06c9c866d1678341d94
parent 3ea3c50
1 file changed +8 -1
modified libpkg/scripts.c
@@ -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)