1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-21 11:10:21 +02:00

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.
This commit is contained in:
Ludovic Courtès 2022-09-07 17:48:12 +02:00
parent 3cd4881504
commit a356ceebee
5 changed files with 59 additions and 2 deletions

View file

@ -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"