Kevin Wolf wrote:
We're leaking file descriptors to child processes. Set FD_CLOEXEC on file
descriptors that don't need to be passed to children to stop this misbehaviour.

Signed-off-by: Kevin Wolf <kw...@redhat.com>

   pid = fork();
   if (pid == 0) {
       int open_max = sysconf(_SC_OPEN_MAX), i;

       for (i = 0; i < open_max; i++) {
           if (i != STDIN_FILENO &&
               i != STDOUT_FILENO &&
               i != STDERR_FILENO &&
               i != fd) {
               close(i);
           }

Handles this in a less invasive way. I think the only problem we have today is that we use popen() for exec: migration. The solution to that though should be to convert popen to a proper fork/exec() with a pipe.

I'd prefer to introduce a single fork/exec helper that behaved properly instead of having to deal with cloexec everywhere.

Regards,

Anthony Liguori


Reply via email to