aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-04-11 18:27:12 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-04-11 18:27:12 +0000
commitabc075c4319ebda03ddcc2bfb4ff5d54596eb92d (patch)
treea4f5438e7b8bbfd11f9e980304e1c750ffa81f8e /src
parentc1ab52dcb9be8995ea7154d91f21a7a16d463033 (diff)
downloadmpd-abc075c4319ebda03ddcc2bfb4ff5d54596eb92d.tar.gz
mpd-abc075c4319ebda03ddcc2bfb4ff5d54596eb92d.tar.xz
mpd-abc075c4319ebda03ddcc2bfb4ff5d54596eb92d.zip
ok, fix some bug due to a child process dieing before the parent can
even assign pid, thus we need to block CHLD signal around fork(); git-svn-id: https://svn.musicpd.org/mpd/trunk@694 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src')
-rw-r--r--src/decode.c9
-rw-r--r--src/directory.c11
-rw-r--r--src/player.c8
3 files changed, 22 insertions, 6 deletions
diff --git a/src/decode.c b/src/decode.c
index ae5e2fcb4..b5f7da213 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -25,6 +25,7 @@
#include "audio.h"
#include "path.h"
#include "log.h"
+#include "sig_handlers.h"
#ifdef HAVE_MAD
#include "mp3_decode.h"
@@ -216,10 +217,13 @@ int decoderInit(PlayerControl * pc, Buffer * cb, AudioFormat *af,
int pid;
int ret;
decode_pid = &(pc->decode_pid);
+
+ blockSignals();
pid = fork();
if(pid==0) {
/* CHILD */
+ unblockSignals();
while(1) {
if(dc->start) {
@@ -279,12 +283,15 @@ int decoderInit(PlayerControl * pc, Buffer * cb, AudioFormat *af,
/* END OF CHILD */
}
else if(pid<0) {
+ unblockSignals();
strncpy(pc->erroredFile,pc->file,MAXPATHLEN);
pc->erroredFile[MAXPATHLEN] = '\0';
pc->error = PLAYER_ERROR_SYSTEM;
return -1;
}
- else *decode_pid = pid;
+
+ *decode_pid = pid;
+ unblockSignals();
return 0;
}
diff --git a/src/directory.c b/src/directory.c
index d34c0d553..a595c061b 100644
--- a/src/directory.c
+++ b/src/directory.c
@@ -117,6 +117,7 @@ void directory_sigChldHandler(int pid, int status) {
DEBUG("direcotry_sigChldHandler: "
"updated db succesffully\n");
}
+ else ERROR("problems updating db\n");
directory_updatePid = 0;
}
}
@@ -127,8 +128,12 @@ int updateInit(FILE * fp, List * pathList) {
return -1;
}
+ /* need to block CHLD signal, cause it can exit before we
+ even get a chance to assign directory_updatePID */
+ blockSignals();
directory_updatePid = fork();
if(directory_updatePid==0) {
+ unblockSignals();
/* child */
struct sigaction sa;
sa.sa_flags = 0;
@@ -163,8 +168,6 @@ int updateInit(FILE * fp, List * pathList) {
}
else {
if(updateDirectory(directory)<0) {
- ERROR("problems updating music "
- "db\n");
exit(EXIT_FAILURE);
}
}
@@ -175,19 +178,19 @@ int updateInit(FILE * fp, List * pathList) {
if(writeDirectoryDB()<0) {
ERROR("problems writing music db file, \"%s\"\n",
directorydb);
- myfprintf(fp,"%s problems writing music db\n",
- COMMAND_RESPOND_ERROR);
exit(EXIT_FAILURE);
}
exit(EXIT_SUCCESS);
}
else if(directory_updatePid < 0) {
+ unblockSignals();
ERROR("updateInit: Problems forking()'ing\n");
myfprintf(fp,"%s problems trying to update\n",
COMMAND_RESPOND_ERROR);
directory_updatePid = 0;
return -1;
}
+ unblockSignals();
directory_updateJobId++;
if(directory_updateJobId > 1<<15) directory_updateJobId = 1;
diff --git a/src/player.c b/src/player.c
index 0659b212c..3bd6508ac 100644
--- a/src/player.c
+++ b/src/player.c
@@ -31,6 +31,7 @@
#include "volume.h"
#include "playerData.h"
#include "permission.h"
+#include "sig_handlers.h"
#include <stdio.h>
#include <sys/types.h>
@@ -88,11 +89,14 @@ void player_sigChldHandler(int pid, int status) {
}
int playerInit() {
+ blockSignals();
player_pid = fork();
-
if(player_pid==0) {
PlayerControl * pc = &(getPlayerData()->playerControl);
struct sigaction sa;
+
+ unblockSignals();
+
sa.sa_flags = 0;
sigemptyset(&sa.sa_mask);
@@ -136,11 +140,13 @@ int playerInit() {
exit(EXIT_SUCCESS);
}
else if(player_pid<0) {
+ unblockSignals();
ERROR("player Problems fork()'ing\n");
player_pid = 0;
return -1;
}
+ unblockSignals();
return 0;
}