diff options
author | Ludovic Courtès <ludo@gnu.org> | 2022-09-07 17:48:12 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2022-09-07 18:00:30 +0200 |
commit | a356ceebee000efe91a2a16dbcaa64d6c6a3a922 (patch) | |
tree | 53bd9e04b45d01e33337252324feb1517a0422d6 /libguile | |
parent | 3cd488150416cac7bddbc270108545330c1fea4f (diff) | |
download | guile-a356ceebee000efe91a2a16dbcaa64d6c6a3a922.tar.gz |
Add support for "e" flag (O_CLOEXEC) to 'open-file'.
* libguile/fports.c (scm_i_mode_to_open_flags): Add 'e' case.
(scm_open_file_with_encoding): Document it.
* test-suite/standalone/test-close-on-exec: New file.
* test-suite/standalone/Makefile.am (check_SCRIPTS, TESTS): Add it.
* doc/ref/api-io.texi (File Ports): Document it.
* NEWS: Update.
Diffstat (limited to 'libguile')
-rw-r--r-- | libguile/fports.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libguile/fports.c b/libguile/fports.c index 4a3c30b88..121d50bf0 100644 --- a/libguile/fports.c +++ b/libguile/fports.c @@ -1,4 +1,4 @@ -/* Copyright 1995-2004,2006-2015,2017-2020 +/* Copyright 1995-2004,2006-2015,2017-2020,2022 Free Software Foundation, Inc. This file is part of Guile. @@ -208,6 +208,9 @@ scm_i_mode_to_open_flags (SCM mode, int *is_binary, const char *FUNC_NAME) flags |= O_BINARY; #endif break; + case 'e': + flags |= O_CLOEXEC; + break; case '0': /* unbuffered: handled later. */ case 'l': /* line buffered: handled during output. */ break; @@ -368,6 +371,9 @@ SCM_DEFINE (scm_i_open_file, "open-file", 2, 0, 1, "@item +\n" "Open the port for both input and output. E.g., @code{r+}: open\n" "an existing file for both input and output.\n" + "@item e\n" + "Mark the underlying file descriptor as close-on-exec, as per the\n" + "@code{O_CLOEXEC} flag.\n" "@item 0\n" "Create an \"unbuffered\" port. In this case input and output\n" "operations are passed directly to the underlying port\n" |