1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:27:35 +00:00

Kernel: Add FIOCLEX and FIONCLEX ioctls

These allow you to turn the close-on-exec flag on/off via ioctl().
This commit is contained in:
Andreas Kling 2022-04-26 14:32:12 +02:00
parent 20d21fad7b
commit b85c8a0b80
2 changed files with 14 additions and 0 deletions

View file

@ -19,6 +19,18 @@ ErrorOr<FlatPtr> Process::sys$ioctl(int fd, unsigned request, FlatPtr arg)
description->set_blocking(TRY(copy_typed_from_user(Userspace<int const*>(arg))) == 0);
return 0;
}
if (request == FIOCLEX) {
m_fds.with_exclusive([&](auto& fds) {
fds[fd].set_flags(fds[fd].flags() | FD_CLOEXEC);
});
return 0;
}
if (request == FIONCLEX) {
m_fds.with_exclusive([&](auto& fds) {
fds[fd].set_flags(fds[fd].flags() & ~FD_CLOEXEC);
});
return 0;
}
TRY(description->file().ioctl(*description, request, arg));
return 0;
}