- signal( SIGINT, SigHandler );
- signal( SIGHUP, SigHandler );
- signal( SIGQUIT, SigHandler );
+ static const int exitsigs[] = { SIGINT, SIGHUP, SIGQUIT, SIGTERM };
+ /* Signals that cause a no-op:
+ * - SIGALRM should not happen, but lets stay on the safe side.
+ * - SIGPIPE might happen with sockets and would crash VLC. It MUST be
+ * blocked by any LibVLC-dependant application, in addition to VLC.
+ * - SIGCHLD is comes after exec*() (such as httpd CGI support) and must
+ * be dequeued to cleanup zombie processes.
+ */
+ static const int dummysigs[] = { SIGALRM, SIGPIPE, SIGCHLD };
+
+ sigset_t set;
+ pthread_t sigth;
+
+ sigemptyset (&set);
+ for (unsigned i = 0; i < sizeof (exitsigs) / sizeof (exitsigs[0]); i++)
+ sigaddset (&set, exitsigs[i]);
+ for (unsigned i = 0; i < sizeof (dummysigs) / sizeof (dummysigs[0]); i++)
+ sigaddset (&set, dummysigs[i]);
+
+ /* Block all these signals */
+ pthread_sigmask (SIG_BLOCK, &set, NULL);
+
+ for (unsigned i = 0; i < sizeof (dummysigs) / sizeof (dummysigs[0]); i++)
+ sigdelset (&set, dummysigs[i]);
+
+ pthread_create (&sigth, NULL, SigHandler, &set);
+#endif