boostorg / boostorg/process

Pipes should be created with O_CLOEXEC

Open
#170 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
145
Forks
151
PR merge metrics
No merged PRs in 30d

Description

On Linux all file handles are inherited by default by child processes. This means that when you create an `opstream` and attach it to a child process, the child process with inherit the input side of the pipe. When you try to close the pipe from the parent process, the operating system will still consider the input of the pipe to be open in the child and the process will most likely block indefinitely. This can be worked around by passing a `boost::process::pipe` created from the result of `pipe2(pipefd, O_CLOEXEC)`, however it would be better to have this behaviour by default. Please note that this must be done at the initial `pipe` call and not with `fcntl` later as otherwise there would be a race condition in multithreaded code.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.