Close all File Handles when Calling posix_spawn

后端 未结 2 503
一整个雨季
一整个雨季 2020-12-18 08:01

I\'d like to spawn a collection of processes using posix_spawn(...) (or something very similar). This function accept an argument of type posix_spawn_file_actions_t, which a

2条回答
  •  既然无缘
    2020-12-18 08:34

    Either set the FD_CLOEXEC (using fcntl()) on all open file descriptors before creating the new process, or have open() set the O_CLOEXEC flag.

    From the posix_spawn() specification:

    If file_actions is a null pointer, then file descriptors open in the calling process shall remain open in the child process, except for those whose close-on- exec flag FD_CLOEXEC is set (see fcntl() ).

提交回复
热议问题