From e8b7285da685866a373b1112115e6dc543991ca9 Mon Sep 17 00:00:00 2001 From: "SND\\weimingzhi_cp" Date: Tue, 23 Oct 2012 08:55:40 +0000 Subject: Do not leave zombie process when running configure utilities. git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@80664 e17a0e51-4ae3-4d35-97c3-1a29b211df97 --- plugins/dfcdrom/cdr.c | 20 +++++++++++++++----- plugins/dfinput/pad.c | 23 +++++++++++++++++++---- plugins/dfsound/cfg.c | 34 ++++++---------------------------- plugins/dfxvideo/cfg.c | 27 +++++++++++++++++++++------ plugins/peopsxgl/gpu.c | 27 +++++++++++++++++++++------ 5 files changed, 82 insertions(+), 49 deletions(-) (limited to 'plugins') diff --git a/plugins/dfcdrom/cdr.c b/plugins/dfcdrom/cdr.c index ab61886e..3456b42d 100644 --- a/plugins/dfcdrom/cdr.c +++ b/plugins/dfcdrom/cdr.c @@ -474,18 +474,28 @@ void ExecCfg(char *arg) { strcpy(cfg, "./cfgDFCdrom"); if (stat(cfg, &buf) != -1) { - if (fork() == 0) { - execl(cfg, "cfgDFCdrom", arg, NULL); + int pid = fork(); + if (pid == 0) { + if (fork() == 0) { + execl(cfg, "cfgDFCdrom", arg, NULL); + } exit(0); + } else if (pid > 0) { + waitpid(pid, NULL, 0); } return; } - strcpy(cfg, "./cfg/DFCdrom"); + strcpy(cfg, "./cfg/cfgDFCdrom"); if (stat(cfg, &buf) != -1) { - if (fork() == 0) { - execl(cfg, "cfgDFCdrom", arg, NULL); + int pid = fork(); + if (pid == 0) { + if (fork() == 0) { + execl(cfg, "cfgDFCdrom", arg, NULL); + } exit(0); + } else if (pid > 0) { + waitpid(pid, NULL, 0); } return; } diff --git a/plugins/dfinput/pad.c b/plugins/dfinput/pad.c index 1074b9ae..d919ae39 100644 --- a/plugins/dfinput/pad.c +++ b/plugins/dfinput/pad.c @@ -651,18 +651,33 @@ void PADregisterVibration(void (*callback)(uint32_t, uint32_t)) { #ifndef _MACOSX long PADconfigure(void) { - if (fork() == 0) { - execl("cfg/cfgDFInput", "cfgDFInput", NULL); + int pid = fork(); + + if (pid == 0) { + if (fork() == 0) { + execl("cfg/cfgDFInput", "cfgDFInput", NULL); + } exit(0); + } else if (pid > 0) { + waitpid(pid, NULL, 0); } + return PSE_PAD_ERR_SUCCESS; } void PADabout(void) { - if (fork() == 0) { - execl("cfg/cfgDFInput", "cfgDFInput", "-about", NULL); + int pid = fork(); + + if (pid == 0) { + if (fork() == 0) { + execl("cfg/cfgDFInput", "cfgDFInput", "-about", NULL); + } exit(0); + } else if (pid > 0) { + waitpid(pid, NULL, 0); } + + return PSE_PAD_ERR_SUCCESS; } #endif diff --git a/plugins/dfsound/cfg.c b/plugins/dfsound/cfg.c index a98a695f..773ddaa2 100644 --- a/plugins/dfsound/cfg.c +++ b/plugins/dfsound/cfg.c @@ -40,42 +40,20 @@ void StartCfgTool(char * pCmdLine) cf=fopen(filename,"rb"); if(cf!=NULL) { + int pid; fclose(cf); - if(fork()==0) + pid=fork(); + if(pid==0) { - execl("./cfgDFSound","cfgDFSound",pCmdLine,NULL); - exit(0); - } - } - else - { - strcpy(filename,"cfg/cfgDFSound"); - cf=fopen(filename,"rb"); - if(cf!=NULL) - { - fclose(cf); if(fork()==0) { - chdir("cfg"); execl("./cfgDFSound","cfgDFSound",pCmdLine,NULL); - exit(0); } + exit(0); } - else + else if(pid>0) { - sprintf(filename,"%s/cfgDFSound",getenv("HOME")); - cf=fopen(filename,"rb"); - if(cf!=NULL) - { - fclose(cf); - if(fork()==0) - { - chdir(getenv("HOME")); - execl("./cfgDFSound","cfgDFSound",pCmdLine,NULL); - exit(0); - } - } - else printf("Sound error: cfgDFSound not found!\n"); + waitpid(pid,NULL,0); } } } diff --git a/plugins/dfxvideo/cfg.c b/plugins/dfxvideo/cfg.c index 09d0485c..a985b1bf 100644 --- a/plugins/dfxvideo/cfg.c +++ b/plugins/dfxvideo/cfg.c @@ -172,27 +172,42 @@ void ExecCfg(char *arg) { strcpy(cfg, "./cfgDFXVideo"); if (stat(cfg, &buf) != -1) { - if (fork() == 0) { - execl(cfg, "cfgDFXVideo", arg, NULL); + int pid = fork(); + if (pid == 0) { + if (fork() == 0) { + execl(cfg, "cfgDFXVideo", arg, NULL); + } exit(0); + } else if (pid > 0) { + waitpid(pid, NULL, 0); } return; } strcpy(cfg, "./cfg/cfgDFXVideo"); if (stat(cfg, &buf) != -1) { - if (fork() == 0) { - execl(cfg, "cfgDFXVideo", arg, NULL); + int pid = fork(); + if (pid == 0) { + if (fork() == 0) { + execl(cfg, "cfgDFXVideo", arg, NULL); + } exit(0); + } else if (pid > 0) { + waitpid(pid, NULL, 0); } return; } sprintf(cfg, "%s/.pcsxr/plugins/cfg/cfgDFXVideo", getenv("HOME")); if (stat(cfg, &buf) != -1) { - if (fork() == 0) { - execl(cfg, "cfgDFXVideo", arg, NULL); + int pid = fork(); + if (pid == 0) { + if (fork() == 0) { + execl(cfg, "cfgDFXVideo", arg, NULL); + } exit(0); + } else if (pid > 0) { + waitpid(pid, NULL, 0); } return; } diff --git a/plugins/peopsxgl/gpu.c b/plugins/peopsxgl/gpu.c index 61daa891..36baa0c9 100644 --- a/plugins/peopsxgl/gpu.c +++ b/plugins/peopsxgl/gpu.c @@ -3012,27 +3012,42 @@ void StartCfgTool(char *arg) // linux: start external cfg tool strcpy(cfg, "./cfgpeopsxgl"); if (stat(cfg, &buf) != -1) { - if (fork() == 0) { - execl(cfg, "cfgpeopsxgl", arg, NULL); + int pid = fork(); + if (pid == 0) { + if (fork() == 0) { + execl(cfg, "cfgpeopsxgl", arg, NULL); + } exit(0); + } else { + waitpid(pid, NULL, 0); } return; } strcpy(cfg, "./cfg/cfgpeopsxgl"); if (stat(cfg, &buf) != -1) { - if (fork() == 0) { - execl(cfg, "cfgpeopsxgl", arg, NULL); + int pid = fork(); + if (pid == 0) { + if (fork() == 0) { + execl(cfg, "cfgpeopsxgl", arg, NULL); + } exit(0); + } else { + waitpid(pid, NULL, 0); } return; } sprintf(cfg, "%s/.pcsxr/plugins/cfg/cfgpeopsxgl", getenv("HOME")); if (stat(cfg, &buf) != -1) { - if (fork() == 0) { - execl(cfg, "cfgpeopsxgl", arg, NULL); + int pid = fork(); + if (pid == 0) { + if (fork() == 0) { + execl(cfg, "cfgpeopsxgl", arg, NULL); + } exit(0); + } else { + waitpid(pid, NULL, 0); } return; } -- cgit v1.2.3