diff options
author | Lennart Poettering <lennart@poettering.net> | 2009-10-31 02:43:47 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2009-10-31 02:43:47 +0100 |
commit | 8e94f653489a0b3d549e61840a5cec711d466ab7 (patch) | |
tree | db22dabf8983df98974f8d49da686a3b2bd41777 /src/pulsecore | |
parent | 2dc37e1214f20aab528ae680e9a85fc8ea143313 (diff) |
daemon: make sure pa has its own session and process group, but is not its leader so that we cannot acquire a tty ever
Diffstat (limited to 'src/pulsecore')
-rw-r--r-- | src/pulsecore/core-util.c | 16 | ||||
-rw-r--r-- | src/pulsecore/core-util.h | 2 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index 738bf065..2b0a60a8 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -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 + +} diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h index d50f79a2..9c9cf78a 100644 --- a/src/pulsecore/core-util.h +++ b/src/pulsecore/core-util.h @@ -265,4 +265,6 @@ int pa_pipe_cloexec(int pipefd[2]); int pa_accept_cloexec(int sockfd, struct sockaddr *addr, socklen_t *addrlen); FILE* pa_fopen_cloexec(const char *path, const char *mode); +void pa_nullify_stdfds(void); + #endif |