! * Function: pipe_cloexec * Creates a pipe and sets FD_CLOEXEC flag on both * read and write descriptors of the pipe. * Parameters: * [out] : A pair of file descriptors. * First element of pair is the read descriptor of pipe. * Second element is the write descriptor of pipe. */
| 613 | * Second element is the write descriptor of pipe. |
| 614 | */ |
| 615 | static inline |
| 616 | std::pair<int, int> pipe_cloexec() noexcept(false) |
| 617 | { |
| 618 | int pipe_fds[2]; |
| 619 | int res = pipe(pipe_fds); |
| 620 | if (res) { |
| 621 | throw OSError("pipe failure", errno); |
| 622 | } |
| 623 | |
| 624 | set_clo_on_exec(pipe_fds[0]); |
| 625 | set_clo_on_exec(pipe_fds[1]); |
| 626 | |
| 627 | return std::make_pair(pipe_fds[0], pipe_fds[1]); |
| 628 | } |
| 629 | #endif |
| 630 | |
| 631 |
no test coverage detected