Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unix library: better API for "close-on-exec" over file descriptors #650

Merged
merged 16 commits into from
Feb 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ Next version (4.05.0):

### Other libraries:

- GPR#650: in the Unix library, add `?cloexec:bool` optional arguments to
functions that create file descriptors (`dup`, `dup2`, `pipe`, `socket`,
`socketpair`, `accept`). Implement these optional arguments in the
most atomic manner provided by the operating system to set (or clear)
the close-on-exec flag at the same time the file descriptor is created,
reducing the risk of race conditions with `exec` or `create_process`
calls running in other threads, and improving security. Also: add a
`O_KEEPEXEC` flag for `openfile` by symmetry with `O_CLOEXEC`.
(Xavier Leroy)

- MPR#7339, GPR#787: Support the '0 dimension' case for bigarrays
(see Bigarray documentation)
(Laurent Mazare,
Expand Down
15 changes: 15 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -1495,6 +1495,21 @@ if sh ./hasgot nice; then
echo "#define HAS_NICE" >> s.h
fi

if sh ./hasgot dup3; then
inf "dup3() found"
echo "#define HAS_DUP3" >> s.h
fi

if sh ./hasgot pipe2; then
inf "pipe2() found"
echo "#define HAS_PIPE2" >> s.h
fi

if sh ./hasgot accept4; then
inf "accept4() found"
echo "#define HAS_ACCEPT4" >> s.h
fi

# Determine if the debugger is supported

if test -n "$with_debugger"; then
Expand Down
10 changes: 6 additions & 4 deletions otherlibs/systhreads/threadUnix.mli
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ val select :

(** {6 Pipes and redirections} *)

val pipe : unit -> Unix.file_descr * Unix.file_descr
val pipe : ?cloexec:bool -> unit -> Unix.file_descr * Unix.file_descr
val open_process_in: string -> in_channel
val open_process_out: string -> out_channel
val open_process: string -> in_channel * out_channel
Expand All @@ -75,9 +75,11 @@ val sleep : int -> unit

(** {6 Sockets} *)

val socket : Unix.socket_domain ->
Unix.socket_type -> int -> Unix.file_descr
val accept : Unix.file_descr -> Unix.file_descr * Unix.sockaddr
val socket :
?cloexec:bool -> Unix.socket_domain -> Unix.socket_type -> int ->
Unix.file_descr
val accept :
?cloexec:bool -> Unix.file_descr -> Unix.file_descr * Unix.sockaddr
val connect : Unix.file_descr -> Unix.sockaddr -> unit
val recv : Unix.file_descr -> bytes ->
int -> int -> Unix.msg_flag list -> int
Expand Down
11 changes: 7 additions & 4 deletions otherlibs/threads/threadUnix.mli
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ val select :

(** {6 Pipes and redirections} *)

val pipe : unit -> Unix.file_descr * Unix.file_descr
val pipe : ?cloexec:bool -> unit -> Unix.file_descr * Unix.file_descr
val open_process_in : string -> in_channel
val open_process_out : string -> out_channel
val open_process : string -> in_channel * out_channel
Expand All @@ -75,11 +75,14 @@ val sleep : int -> unit

(** {6 Sockets} *)

val socket : Unix.socket_domain -> Unix.socket_type -> int -> Unix.file_descr
val socket :
?cloexec:bool -> Unix.socket_domain -> Unix.socket_type -> int ->
Unix.file_descr
val socketpair :
Unix.socket_domain -> Unix.socket_type -> int ->
?cloexec:bool -> Unix.socket_domain -> Unix.socket_type -> int ->
Unix.file_descr * Unix.file_descr
val accept : Unix.file_descr -> Unix.file_descr * Unix.sockaddr
val accept :
?cloexec:bool -> Unix.file_descr -> Unix.file_descr * Unix.sockaddr
val connect : Unix.file_descr -> Unix.sockaddr -> unit
val recv :
Unix.file_descr -> bytes -> int -> int -> Unix.msg_flag list -> int
Expand Down
Loading