aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/directory.c11
-rw-r--r--src/directory.h2
-rw-r--r--src/player.c18
-rw-r--r--src/player.h2
-rw-r--r--src/sig_handlers.c8
-rw-r--r--src/signal_check.c4
6 files changed, 31 insertions, 14 deletions
diff --git a/src/directory.c b/src/directory.c
index b4634c42f..8a193d5a2 100644
--- a/src/directory.c
+++ b/src/directory.c
@@ -31,6 +31,7 @@
#include "volume.h"
#include "mpd_types.h"
#include "sig_handlers.h"
+#include "player.h"
#include <string.h>
#include <sys/types.h>
@@ -101,6 +102,10 @@ Directory * getDirectory(char * name);
Song * getSongDetails(char * file, char ** shortnameRet,
Directory ** directoryRet);
+void clearUpdatePid() {
+ directory_updatePid = 0;
+}
+
int isUpdatingDB() {
if(directory_updatePid>0 || directory_reReadDB) {
return directory_updateJobId;
@@ -120,7 +125,7 @@ void directory_sigChldHandler(int pid, int status) {
"updated db succesffully\n");
directory_reReadDB = 1;
}
- directory_updatePid = 0;
+ clearUpdatePid();
}
}
@@ -144,8 +149,10 @@ int updateInit(FILE * fp, List * pathList) {
blockSignals();
directory_updatePid = fork();
if(directory_updatePid==0) {
- unblockSignals();
/* child */
+ clearPlayerPid();
+
+ unblockSignals();
finishSigHandlers();
close(listenSocket);
diff --git a/src/directory.h b/src/directory.h
index 6e4d57fbf..a850154e4 100644
--- a/src/directory.h
+++ b/src/directory.h
@@ -31,6 +31,8 @@ extern char directorydb[MAXPATHLEN+1];
void readDirectoryDBIfUpdateIsFinished();
+void clearUpdatePid();
+
int isUpdatingDB();
void directory_sigChldHandler(int pid, int status);
diff --git a/src/player.c b/src/player.c
index 417b76f69..9376d01b3 100644
--- a/src/player.c
+++ b/src/player.c
@@ -46,13 +46,15 @@
#include <fcntl.h>
volatile int player_pid = 0;
-volatile int player_termSent = 0;
+
+void clearPlayerPid() {
+ player_pid = 0;
+}
void resetPlayer() {
int pid;
- player_pid = 0;
- player_termSent = 0;
+ clearPlayerPid();
getPlayerData()->playerControl.stop = 0;
getPlayerData()->playerControl.play = 0;
getPlayerData()->playerControl.pause = 0;
@@ -97,6 +99,8 @@ int playerInit() {
PlayerControl * pc = &(getPlayerData()->playerControl);
struct sigaction sa;
+ clearUpdatePid();
+
unblockSignals();
sa.sa_flags = 0;
@@ -104,11 +108,11 @@ int playerInit() {
finishSigHandlers();
sa.sa_handler = decodeSigHandler;
- sigaction(SIGCHLD,&sa,NULL);
- sigaction(SIGTERM,&sa,NULL);
- sigaction(SIGINT,&sa,NULL);
+ while(sigaction(SIGCHLD,&sa,NULL)<0 && errno==EINTR);
+ while(sigaction(SIGTERM,&sa,NULL)<0 && errno==EINTR);
+ while(sigaction(SIGINT,&sa,NULL)<0 && errno==EINTR);
- close(listenSocket);
+ while(close(listenSocket)<0 && errno==EINTR);
freeAllInterfaces();
closeMp3Directory();
finishPlaylist();
diff --git a/src/player.h b/src/player.h
index 7bfd1e559..8c02b8f34 100644
--- a/src/player.h
+++ b/src/player.h
@@ -79,6 +79,8 @@ typedef struct _PlayerControl {
volatile int decode_pid;
} PlayerControl;
+void clearPlayerPid();
+
void player_sigChldHandler(int pid, int status);
int playerPlay(FILE * fp, char * utf8file);
diff --git a/src/sig_handlers.c b/src/sig_handlers.c
index 9ec23df4b..126777de6 100644
--- a/src/sig_handlers.c
+++ b/src/sig_handlers.c
@@ -67,9 +67,9 @@ void initSigHandlers() {
sa.sa_flags = 0;
sigemptyset(&sa.sa_mask);
sa.sa_handler = SIG_IGN;
- sigaction(SIGPIPE,&sa,NULL);
+ while(sigaction(SIGPIPE,&sa,NULL)<0 && errno==EINTR);
sa.sa_handler = chldSigHandler;
- sigaction(SIGCHLD,&sa,NULL);
+ while(sigaction(SIGCHLD,&sa,NULL)<0 && errno==EINTR);
signal_handle(SIGUSR1);
signal_handle(SIGINT);
signal_handle(SIGTERM);
@@ -90,7 +90,7 @@ void blockSignals() {
sigaddset(&sset,SIGCHLD);
sigaddset(&sset,SIGUSR1);
sigaddset(&sset,SIGHUP);
- sigprocmask(SIG_BLOCK,&sset,NULL);
+ while(sigprocmask(SIG_BLOCK,&sset,NULL)<0 && errno==EINTR);
}
void unblockSignals() {
@@ -100,5 +100,5 @@ void unblockSignals() {
sigaddset(&sset,SIGCHLD);
sigaddset(&sset,SIGUSR1);
sigaddset(&sset,SIGHUP);
- sigprocmask(SIG_UNBLOCK,&sset,NULL);
+ while(sigprocmask(SIG_UNBLOCK,&sset,NULL)<0 && errno==EINTR);
}
diff --git a/src/signal_check.c b/src/signal_check.c
index 3926ae7b0..b46344488 100644
--- a/src/signal_check.c
+++ b/src/signal_check.c
@@ -1,5 +1,7 @@
#include "signal_check.h"
+#include <errno.h>
+
volatile sig_atomic_t __caught_signals[NSIG];
static void __signal_handler(int sig)
@@ -12,7 +14,7 @@ static void __set_signal_handler(int sig, void (* handler)(int))
struct sigaction act;
act.sa_flags = 0;
act.sa_handler = handler;
- sigaction(sig, &act, 0);
+ while(sigaction(sig, &act, 0) && errno==EINTR);
}
void signal_handle(int sig)