Commit d10ea719 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Dequeue "dummy" signals

parent 0b1c15a3
...@@ -233,13 +233,16 @@ int main( int i_argc, char *ppsz_argv[] ) ...@@ -233,13 +233,16 @@ int main( int i_argc, char *ppsz_argv[] )
*****************************************************************************/ *****************************************************************************/
static void *SigHandler (void *data) static void *SigHandler (void *data)
{ {
const sigset_t *set = (sigset_t *)data; const sigset_t *exitset = (sigset_t *)data;
sigset_t fullset;
time_t abort_time = 0; time_t abort_time = 0;
pthread_sigmask (SIG_BLOCK, exitset, &fullset);
for (;;) for (;;)
{ {
int i_signal, state; int i_signal, state;
(void)sigwait (set, &i_signal); (void)sigwait (&fullset, &i_signal);
#ifdef __APPLE__ #ifdef __APPLE__
/* In Mac OS X up to 10.4.8 sigwait (among others) is not a pthread /* In Mac OS X up to 10.4.8 sigwait (among others) is not a pthread
...@@ -247,6 +250,9 @@ static void *SigHandler (void *data) ...@@ -247,6 +250,9 @@ static void *SigHandler (void *data)
pthread_testcancel(); pthread_testcancel();
#endif #endif
if (!sigismember (exitset, i_signal))
continue; /* Ignore "dummy" signals */
/* Once a signal has been trapped, the termination sequence will be /* Once a signal has been trapped, the termination sequence will be
* armed and subsequent signals will be ignored to avoid sending * armed and subsequent signals will be ignored to avoid sending
* signals to a libvlc structure having been destroyed */ * signals to a libvlc structure having been destroyed */
...@@ -267,7 +273,7 @@ static void *SigHandler (void *data) ...@@ -267,7 +273,7 @@ static void *SigHandler (void *data)
if (time (NULL) <= abort_time) if (time (NULL) <= abort_time)
{ {
/* If user asks again more than 2 seconds later, die badly */ /* If user asks again more than 2 seconds later, die badly */
pthread_sigmask (SIG_UNBLOCK, set, NULL); pthread_sigmask (SIG_UNBLOCK, exitset, NULL);
fprintf (stderr, "user insisted too much, dying badly\n"); fprintf (stderr, "user insisted too much, dying badly\n");
abort (); abort ();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment