dbus bugfix - close inherited filedescriptors

Thiago Macieira thiago at kde.org
Fri May 16 00:06:33 PDT 2008


Daniel P. Berrange wrote:
>IMHO, it should close 0, 1, 2 as well, and re-open them to
>point to /dev/null.

stdout and stderr are already reopened to pipes that the library uses to 
read the dbus-launch output. stdin is closed.

Current code:
      /* set-up stdXXX */
      close (address_pipe[READ_END]);
      close (errors_pipe[READ_END]);
      close (0);                /* close stdin */
      close (1);                /* close stdout */
      close (2);                /* close stderr */

      if (dup2 (fd, 0) == -1)
        _exit (1);
      if (dup2 (address_pipe[WRITE_END], 1) == -1)
        _exit (1);
      if (dup2 (errors_pipe[WRITE_END], 2) == -1)
        _exit (1);

where fd is /dev/null.

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://lists.freedesktop.org/archives/dbus/attachments/20080516/9b1fb7eb/attachment.pgp 


More information about the dbus mailing list