+ /* Wait for a termination signal */
+ pthread_t self = pthread_self ();
+ libvlc_set_exit_handler (vlc, vlc_kill, &self);
+
+ if (signal_ignored (SIGHUP)) /* <- needed to handle nohup properly */
+ sigdelset (&set, SIGHUP);
+ sigdelset (&set, SIGPIPE);
+
+ int signum;
+ do
+ sigwait (&set, &signum);
+ while (signum == SIGCHLD);
+
+ /* Restore default signal behaviour after 3 seconds */
+ sigemptyset (&set);
+ sigaddset (&set, SIGINT);
+ sigaddset (&set, SIGALRM);
+ signal (SIGINT, SIG_IGN);
+ signal (SIGALRM, exit_timeout);
+ pthread_sigmask (SIG_UNBLOCK, &set, NULL);
+ alarm (3);
+
+ /* Cleanup */
+out:
+ if (vlc != NULL)
+ libvlc_release (vlc);
+ for (int i = 1; i < argc; i++)