From: Andre Noll Date: Sat, 17 Nov 2007 17:13:55 +0000 (+0100) Subject: fade.c: Fix client_cmd() X-Git-Tag: v0.3.0~113^2~10 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=0b5f380ddc094b9dc3741dc2beaf7b775e4946d6;hp=d013a58cb2f7ed1a36b666a7ca1f9406a92d04bd;ds=sidebyside fade.c: Fix client_cmd() We have to wait for children to terminate because otherwise the client commands may be executed in random order. Since no caller checked the return value of client_cmd(), make it abort on errors and change the return value to void. Also, each caller only passed one string, so make it take only a char * pointer. --- diff --git a/fade.c b/fade.c index f269f029..c86b9385 100644 --- a/fade.c +++ b/fade.c @@ -149,7 +149,7 @@ out: close(mixer_fd); } -static int client_cmd(const char *cmd,...) +static void client_cmd(const char *cmd) { int ret, fds[3] = {0, 0, 0}; pid_t pid; @@ -158,7 +158,11 @@ static int client_cmd(const char *cmd,...) PARA_INFO_LOG("%s\n", cmdline); ret = para_exec_cmdline_pid(&pid, cmdline, fds); free(cmdline); - return ret; + if (ret < 0) + exit(EXIT_FAILURE); + do + ret = wait(NULL); + while (ret != -1 && errno != ECHILD); } static void change_afs_mode_and_play(char *afs_mode)