-#if !defined(WIN32) && !defined(UNDER_CE)
- pthread_cancel (sigth);
-# ifdef __APPLE__
- /* In Mac OS X up to 10.4.8 sigwait (among others) is not a pthread
- * cancellation point, so we throw a dummy quit signal to end
- * sigwait() in the sigth thread */
- pthread_kill (sigth, SIGQUIT);
-# endif
- pthread_join (sigth, NULL);
-#endif
-
- return -i_ret;
-}
-
-#if !defined(WIN32) && !defined(UNDER_CE)
-/*****************************************************************************
- * SigHandler: system signal handler
- *****************************************************************************
- * This thread receives all handled signals synchronously.
- * It tries to end the program in a clean way.
- *****************************************************************************/
-static void *SigHandler (void *data)
-{
- const sigset_t *exitset = (sigset_t *)data;
- sigset_t fullset;
- time_t abort_time = 0;
-
- pthread_sigmask (SIG_BLOCK, exitset, &fullset);
-
- for (;;)
- {
- int i_signal, state;
- if( sigwait (&fullset, &i_signal) != 0 )
- continue;
-
-#ifdef __APPLE__
- /* In Mac OS X up to 10.4.8 sigwait (among others) is not a pthread
- * cancellation point */
- pthread_testcancel();
-#endif
-
- if (!sigismember (exitset, i_signal))
- continue; /* Ignore "dummy" signals */
-
- /* Once a signal has been trapped, the termination sequence will be
- * armed and subsequent signals will be ignored to avoid sending
- * signals to a libvlc structure having been destroyed */
-
- pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &state);
- if (abort_time == 0 || time (NULL) > abort_time)
- {
- time (&abort_time);
- abort_time += 2;
-
- fprintf (stderr, "signal %d received, terminating vlc - do it "
- "again quickly in case it gets stuck\n", i_signal);
-
- /* Acknowledge the signal received */
- Kill ();
- }
- else /* time (NULL) <= abort_time */
- {
- /* If user asks again more than 2 seconds later, die badly */
- pthread_sigmask (SIG_UNBLOCK, exitset, NULL);
- fprintf (stderr, "user insisted too much, dying badly\n");
-#ifdef __APPLE__
- /* On Mac OS X, use exit(-1) as it doesn't trigger
- * backtrace generation, whereas abort() does.
- * The backtrace generation trigger a Crash Dialog
- * And takes way too much time, which is not what
- * we want. */
- exit (-1);
-#else
- abort ();
-#endif
- }
- pthread_setcancelstate (state, NULL);
- }
- /* Never reached */
-}
-
-
-static void KillOnce (void)
-{
- VLC_Die (0);
-}
-
-static void Kill (void)
-{
- static pthread_once_t once = PTHREAD_ONCE_INIT;
- pthread_once (&once, KillOnce);
-}
-
-#endif
-
-#if defined(UNDER_CE)
-# if defined( _MSC_VER ) && defined( UNDER_CE )
-# include "vlc_common.h"
-# endif
-/*****************************************************************************
- * WinMain: parse command line, start interface and spawn threads. (WinCE only)
- *****************************************************************************/
-int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
- LPTSTR lpCmdLine, int nCmdShow )
-{
- char **argv, psz_cmdline[MAX_PATH];
- int argc, i_ret;
-
- WideCharToMultiByte( CP_ACP, 0, lpCmdLine, -1,
- psz_cmdline, MAX_PATH, NULL, NULL );
-
- argv = vlc_parse_cmdline( psz_cmdline, &argc );
- argv = realloc( argv, (argc + 1) * sizeof(char *) );
- if( !argv ) return -1;
-
- if( argc ) memmove( argv + 1, argv, argc * sizeof(char *) );
- argv[0] = ""; /* Fake program path */
-
- i_ret = main( argc + 1, argv );
-
- /* No need to free the argv memory */