mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:37:35 +00:00
Add close-on-exec flag for file descriptors.
I was surprised to find that dup()'ed fds don't share the close-on-exec flag. That means it has to be stored separately from the FileDescriptor object.
This commit is contained in:
parent
19b9401487
commit
97c799576a
10 changed files with 74 additions and 35 deletions
|
@ -51,7 +51,6 @@ RetainPtr<FileDescriptor> FileDescriptor::clone()
|
|||
descriptor->m_currentOffset = m_currentOffset;
|
||||
#ifdef SERENITY
|
||||
descriptor->m_isBlocking = m_isBlocking;
|
||||
descriptor->m_fd_flags = m_fd_flags;
|
||||
descriptor->m_file_flags = m_file_flags;
|
||||
#endif
|
||||
return descriptor;
|
||||
|
|
|
@ -53,10 +53,7 @@ public:
|
|||
void setBlocking(bool b) { m_isBlocking = b; }
|
||||
|
||||
dword file_flags() const { return m_file_flags; }
|
||||
int set_file_flags(dword flags) { m_file_flags = flags; return 0; }
|
||||
|
||||
dword fd_flags() const { return m_fd_flags; }
|
||||
int set_fd_flags(dword flags) { m_fd_flags = flags; return 0; }
|
||||
void set_file_flags(dword flags) { m_file_flags = flags; }
|
||||
|
||||
bool is_fifo() const { return m_fifo; }
|
||||
FIFO::Direction fifo_direction() { return m_fifo_direction; }
|
||||
|
@ -77,7 +74,6 @@ private:
|
|||
|
||||
#ifdef SERENITY
|
||||
bool m_isBlocking { true };
|
||||
dword m_fd_flags { 0 };
|
||||
dword m_file_flags { 0 };
|
||||
|
||||
RetainPtr<FIFO> m_fifo;
|
||||
|
|
|
@ -25,6 +25,8 @@ namespace Unix {
|
|||
#define F_GETFL 3
|
||||
#define F_SETFL 4
|
||||
|
||||
#define FD_CLOEXEC 1
|
||||
|
||||
/* c_cc characters */
|
||||
#define VINTR 0
|
||||
#define VQUIT 1
|
||||
|
|
|
@ -14,8 +14,15 @@
|
|||
#define O_RDONLY 0
|
||||
#define O_WRONLY 1
|
||||
#define O_RDWR 2
|
||||
#define O_CREAT 0100
|
||||
#define O_EXCL 0200
|
||||
#define O_NOCTTY 0400
|
||||
#define O_TRUNC 01000
|
||||
#define O_APPEND 02000
|
||||
#define O_NONBLOCK 04000
|
||||
#define O_DIRECTORY 00200000
|
||||
#define O_NOFOLLOW 00400000
|
||||
#define O_CLOEXEC 02000000
|
||||
#define O_NOFOLLOW_NOERROR 0x4000000
|
||||
|
||||
class CharacterDevice;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue