diff options
author | Ludovic Courtès <ludo@gnu.org> | 2022-05-20 17:12:01 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2022-05-20 18:46:07 +0200 |
commit | a4994d739306abcf3f36706012fb88b35a970e6b (patch) | |
tree | e348700851cfc37bd405f1ddb68fe57e89475702 /guix/inferior.scm | |
parent | 102e3833601b75e019acb6c0d96dc2ed68b947cb (diff) |
inferior: Close duplicate socketpair file descriptor.
* guix/inferior.scm (open-bidirectional-pipe): Pass SOCK_CLOEXEC to
'socketpair'.
* tests/inferior.scm ("close-inferior"): Add test.
Diffstat (limited to 'guix/inferior.scm')
-rw-r--r-- | guix/inferior.scm | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/guix/inferior.scm b/guix/inferior.scm index 6949bb3687..54200b75e4 100644 --- a/guix/inferior.scm +++ b/guix/inferior.scm @@ -141,7 +141,11 @@ regular file port (socket). This is equivalent to (open-pipe* OPEN_BOTH ...) except that the result is a regular file port that can be passed to 'select' ('open-pipe*' returns a custom binary port)." - (match (socketpair AF_UNIX SOCK_STREAM 0) + ;; Make sure the sockets are close-on-exec; failing to do that, a second + ;; inferior (for instance) would inherit the underlying file descriptor, and + ;; thus (close-port PARENT) in the original process would have no effect: + ;; the REPL process wouldn't get EOF on standard input. + (match (socketpair AF_UNIX (logior SOCK_STREAM SOCK_CLOEXEC) 0) ((parent . child) (match (primitive-fork) (0 |