implemented new CLI command: dump

add prefork() and postfork() arguments to pa_context_connect_spawn()


git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@184 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
Lennart Poettering 2004-09-07 17:06:54 +00:00
parent 93c8fe6577
commit 70007175d2
6 changed files with 130 additions and 20 deletions

View file

@ -571,9 +571,9 @@ static int is_running(void) {
return 1;
}
int pa_context_connect_spawn(struct pa_context *c, void (*atfork)(void)) {
int pa_context_connect_spawn(struct pa_context *c, void (*atfork)(void), void (*prefork)(void), void (*postfork)(void)) {
pid_t pid;
int status;
int status, r;
int fds[2] = { -1, -1} ;
struct pa_iochannel *io;
@ -586,9 +586,16 @@ int pa_context_connect_spawn(struct pa_context *c, void (*atfork)(void)) {
goto fail;
}
if (prefork)
prefork();
if ((pid = fork()) < 0) {
pa_log(__FILE__": fork() failed: %s\n", strerror(errno));
pa_context_fail(c, PA_ERROR_INTERNAL);
if (postfork)
postfork();
goto fail;
} else if (!pid) {
char t[64];
@ -610,7 +617,13 @@ int pa_context_connect_spawn(struct pa_context *c, void (*atfork)(void)) {
}
/* Parent */
if (waitpid(pid, &status, 0) < 0) {
r = waitpid(pid, &status, 0);
if (postfork)
postfork();
if (r < 0) {
pa_log(__FILE__": waitpid() failed: %s\n", strerror(errno));
pa_context_fail(c, PA_ERROR_INTERNAL);
goto fail;