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
This commit is contained in:
Warren Dukes
2004-04-11 18:27:12 +00:00
parent c1ab52dcb9
commit abc075c431
3 changed files with 22 additions and 6 deletions

View File

@@ -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;
}