Commit eb73a30f7effc51c1cfee2864102635e3659f87a

Stefan Sperling 2019-03-07T13:00:23

do not deadlock in waitpid() when user hits Ctrl-C

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/lib/privsep.c b/lib/privsep.c
index a9a2ff8..7e6cbb9 100644
--- a/lib/privsep.c
+++ b/lib/privsep.c
@@ -95,7 +95,8 @@ got_privsep_wait_for_child(pid_t pid)
 {
 	int child_status;
 
-	waitpid(pid, &child_status, 0);
+	if (waitpid(pid, &child_status, WNOHANG) == 0)
+		return NULL;
 
 	if (!WIFEXITED(child_status))
 		return got_error(GOT_ERR_PRIVSEP_DIED);