File tree 1 file changed +13
-3
lines changed
1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -38,13 +38,18 @@ let kill_and_close_ (self : t) =
38
38
: Thread. t);
39
39
40
40
(* kill zombies *)
41
- let code = try fst @@ Unix. waitpid [] self.pid with _ -> max_int in
41
+ let code =
42
+ try
43
+ ignore (Unix. sigprocmask Unix. SIG_BLOCK [ Sys. sigchld ]);
44
+ fst @@ Unix. waitpid [] self.pid
45
+ with _ -> max_int
46
+ in
42
47
Fut. fulfill_idempotent self._st.promise_code @@ Ok code
43
48
)
44
49
45
50
let run_ ?(env = Unix. environment () ) cmd args : t =
46
51
(* block sigpipe *)
47
- ignore (Unix. sigprocmask Unix. SIG_BLOCK [ Sys. sigpipe ]);
52
+ ignore (Unix. sigprocmask Unix. SIG_BLOCK [ Sys. sigpipe; Sys. sigchld ]);
48
53
(* make pipes, to give the appropriate ends to the subprocess *)
49
54
let stdout, p_stdout = Unix. pipe () in
50
55
let stderr, p_stderr = Unix. pipe () in
@@ -87,7 +92,12 @@ let signal self s = Unix.kill self.pid s
87
92
88
93
let wait (self : t ) : int =
89
94
Log. debug (fun k -> k " (popen.wait %a)" pp self);
90
- let res = try snd @@ Unix. waitpid [] self.pid with _ -> Unix. WEXITED 0 in
95
+ let res =
96
+ try
97
+ ignore (Unix. sigprocmask Unix. SIG_BLOCK [ Sys. sigchld ]);
98
+ snd @@ Unix. waitpid [] self.pid
99
+ with _ -> Unix. WEXITED 0
100
+ in
91
101
kill_and_close_ self;
92
102
let res =
93
103
match res with
You can’t perform that action at this time.
0 commit comments