qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] Don't leak file descriptors


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH] Don't leak file descriptors
Date: Mon, 16 Nov 2009 17:26:19 -0600
User-agent: Thunderbird 2.0.0.23 (X11/20090825)

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 <address@hidden>

   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

[Prev in Thread] Current Thread [Next in Thread]