1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 20:07:34 +00:00

SystemServer: Explicitly open /dev/null for services without StdIO

Spawning services with nothing open at all on the standard I/O fds is
way too harsh. We now open /dev/null for them instead.
This commit is contained in:
Andreas Kling 2020-01-04 13:15:01 +01:00
parent c2b7c43f3c
commit 9bd4bf41fb
2 changed files with 6 additions and 1 deletions

View file

@ -190,6 +190,11 @@ void Service::spawn()
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
int fd = open("/dev/null", O_RDWR);
ASSERT(fd == STDIN_FILENO);
dup2(STDIN_FILENO, STDOUT_FILENO);
dup2(STDIN_FILENO, STDERR_FILENO);
}
if (!m_socket_path.is_null()) {