daemon: make sure pa has its own session and process group, but is not its leader so that we cannot acquire a tty ever

This commit is contained in:
Lennart Poettering 2009-10-31 02:43:47 +01:00
parent 2dc37e1214
commit 8e94f65348
3 changed files with 38 additions and 20 deletions

View file

@ -2999,3 +2999,19 @@ finish:
pa_make_fd_cloexec(fileno(f));
return f;
}
void pa_nullify_stdfds(void) {
#ifndef OS_IS_WIN32
pa_close(STDIN_FILENO);
pa_close(STDOUT_FILENO);
pa_close(STDERR_FILENO);
pa_assert_se(open("/dev/null", O_RDONLY) == STDIN_FILENO);
pa_assert_se(open("/dev/null", O_WRONLY) == STDOUT_FILENO);
pa_assert_se(open("/dev/null", O_WRONLY) == STDERR_FILENO);
#else
FreeConsole();
#endif
}