public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-7419] libstdc++: Use close-on-exec for file descriptors in filesystem::copy_file Date: Tue, 6 Jun 2023 13:34:20 +0000 (GMT) [thread overview] Message-ID: <20230606133420.BECBD3858416@sourceware.org> (raw) https://gcc.gnu.org/g:bae27ba9dedc521b8bb093347ef84bb35701518d commit r13-7419-gbae27ba9dedc521b8bb093347ef84bb35701518d Author: Jonathan Wakely <jwakely@redhat.com> Date: Mon Jun 5 17:45:37 2023 +0100 libstdc++: Use close-on-exec for file descriptors in filesystem::copy_file libstdc++-v3/ChangeLog: * src/filesystem/ops-common.h (do_copy_file) [O_CLOEXEC]: Set close-on-exec flag on file descriptors. (cherry picked from commit 7e8e071c4b64f1b6ea5ddf528724fc793a0f0e36) Diff: --- libstdc++-v3/src/filesystem/ops-common.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libstdc++-v3/src/filesystem/ops-common.h b/libstdc++-v3/src/filesystem/ops-common.h index c95511b5c95..35aebff48c1 100644 --- a/libstdc++-v3/src/filesystem/ops-common.h +++ b/libstdc++-v3/src/filesystem/ops-common.h @@ -457,25 +457,26 @@ _GLIBCXX_BEGIN_NAMESPACE_FILESYSTEM int fd; }; - int iflag = O_RDONLY; + int common_flags = 0; +#ifdef O_CLOEXEC + common_flags |= O_CLOEXEC; +#endif #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS - iflag |= O_BINARY; + common_flags |= O_BINARY; #endif + const int iflag = O_RDONLY | common_flags; CloseFD in = { posix::open(from, iflag) }; if (in.fd == -1) { ec.assign(errno, std::generic_category()); return false; } - int oflag = O_WRONLY|O_CREAT; + int oflag = O_WRONLY | O_CREAT | common_flags; if (options.overwrite || options.update) oflag |= O_TRUNC; else oflag |= O_EXCL; -#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS - oflag |= O_BINARY; -#endif CloseFD out = { posix::open(to, oflag, S_IWUSR) }; if (out.fd == -1) {
reply other threads:[~2023-06-06 13:34 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230606133420.BECBD3858416@sourceware.org \ --to=redi@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).