Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Prevent potential hang with lua scripts
Baptiste Daroussin committed 6 years ago
commit 03954461579813f29ccc9d9eb2a79167cc62855f
parent 562fa0b
1 file changed +8 -1
modified libpkg/lua_scripts.c
@@ -303,12 +303,19 @@ pkg_lua_script_run(struct pkg * const pkg, pkg_lua_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)