- signal( SIGINT, SigHandler );
- signal( SIGHUP, SigHandler );
- signal( SIGQUIT, SigHandler );
-
- /* Other signals */
- signal( SIGALRM, SIG_IGN );
- signal( SIGPIPE, SIG_IGN );
-#endif
+ static const int sigs[] = {
+ SIGINT, SIGHUP, SIGQUIT, SIGTERM,
+ /* Signals that cause a no-op:
+ * - SIGPIPE might happen with sockets and would crash VLC. It MUST be
+ * blocked by any LibVLC-dependent application, in addition to VLC.
+ * - SIGCHLD is comes after exec*() (such as httpd CGI support) and must
+ * be dequeued to cleanup zombie processes.
+ */
+ SIGPIPE, SIGCHLD
+ };
+
+ sigset_t set;
+ sigemptyset (&set);
+ for (unsigned i = 0; i < sizeof (sigs) / sizeof (sigs[0]); i++)
+ sigaddset (&set, sigs[i]);
+
+ /* Block all these signals */
+ pthread_sigmask (SIG_BLOCK, &set, NULL);
+
+ /* Note that FromLocale() can be used before libvlc is initialized */
+ for (int i = 0; i < i_argc; i++)
+ if ((ppsz_argv[i] = FromLocale (ppsz_argv[i])) == NULL)
+ return 1; // BOOM!
+
+ libvlc_exception_t ex, dummy;
+ libvlc_exception_init (&ex);
+ libvlc_exception_init (&dummy);