From a356ceebee000efe91a2a16dbcaa64d6c6a3a922 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 7 Sep 2022 17:48:12 +0200 Subject: 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. --- libguile/fports.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'libguile') 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" -- cgit v1.2.1