! * 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. */
| 363 | * Second element is the write descriptor of pipe. |
| 364 | */ |
| 365 | static inline |
| 366 | std::pair<int, int> pipe_cloexec() noexcept(false) |
| 367 | { |
| 368 | int pipe_fds[2]; |
| 369 | int res = pipe(pipe_fds); |
| 370 | if (res) { |
| 371 | throw OSError("pipe failure", errno); |
| 372 | } |
| 373 | |
| 374 | set_clo_on_exec(pipe_fds[0]); |
| 375 | set_clo_on_exec(pipe_fds[1]); |
| 376 | |
| 377 | return std::make_pair(pipe_fds[0], pipe_fds[1]); |
| 378 | } |
| 379 | #endif |
| 380 | |
| 381 |
no test coverage detected