Skip to content

Commit 1f9bd44

Browse files
committed
Simplify Unix cloexec for passing /dev/null to sub-processes
1 parent a2c36be commit 1f9bd44

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/unix/lwt_process.cppo.ml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,9 @@ let unix_redirect fd redirection = match redirection with
122122
| `Keep ->
123123
()
124124
| `Dev_null ->
125-
Unix.close fd;
126125
let dev_null = Unix.openfile "/dev/null" [Unix.O_RDWR; Unix.O_KEEPEXEC] 0o666 in
127-
if fd <> dev_null then begin
128-
Unix.dup2 dev_null fd;
129-
Unix.close dev_null
130-
end
126+
Unix.dup2 dev_null fd;
127+
Unix.close dev_null
131128
| `Close ->
132129
Unix.close fd
133130
| `FD_copy fd' ->

0 commit comments

Comments
 (0)