utils: Fix FileDescriptor duplicates potentially leaking to child processes
dup() doesn't duplicate flags such as FD_CLOEXEC.
This commit is contained in:
parent
8b4a0c35cc
commit
60dc812b21
1 changed files with 2 additions and 1 deletions
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
#include "filedescriptor.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <utility>
|
||||
|
||||
|
@ -58,7 +59,7 @@ int FileDescriptor::take()
|
|||
FileDescriptor FileDescriptor::duplicate() const
|
||||
{
|
||||
if (m_fd != -1) {
|
||||
return FileDescriptor{dup(m_fd)};
|
||||
return FileDescriptor{fcntl(m_fd, F_DUPFD_CLOEXEC, 0)};
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue