kernel+libc: Implement O_CLOEXEC
This commit is contained in:
parent
d48d0efb07
commit
374a9ff7b8
@ -6,6 +6,7 @@
|
||||
#include "thread/Scheduler.h"
|
||||
#include "thread/ThreadImage.h"
|
||||
#include <bits/modes.h>
|
||||
#include <bits/open-flags.h>
|
||||
#include <luna/CString.h>
|
||||
#include <luna/ScopeGuard.h>
|
||||
#include <luna/Vector.h>
|
||||
@ -76,8 +77,11 @@ Result<u64> sys_exec(Registers* regs, SyscallArgs args)
|
||||
|
||||
guard.deactivate();
|
||||
|
||||
// FIXME: Close O_CLOEXEC file descriptors.
|
||||
// for (int i = 0; i < FD_MAX; i++) { current->fd_table[i] = {}; }
|
||||
for (int i = 0; i < FD_MAX; i++)
|
||||
{
|
||||
auto& descriptor = current->fd_table[i];
|
||||
if (descriptor->flags & O_CLOEXEC) descriptor = {};
|
||||
}
|
||||
|
||||
MMU::delete_userspace_page_directory(current->directory);
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <bits/open-flags.h>
|
||||
|
||||
// These flags are needed after open(), the rest only affect open().
|
||||
constexpr int FLAGS_TO_KEEP = O_RDWR | O_APPEND | O_NONBLOCK;
|
||||
constexpr int FLAGS_TO_KEEP = O_RDWR | O_APPEND | O_NONBLOCK | O_CLOEXEC;
|
||||
|
||||
Result<u64> sys_open(Registers*, SyscallArgs args)
|
||||
{
|
||||
|
@ -11,5 +11,6 @@
|
||||
#define O_EXCL 16
|
||||
#define O_TRUNC 32
|
||||
#define O_NONBLOCK 64
|
||||
#define O_CLOEXEC 128
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user