Changeset 1d58919125812d569c23bde687e42fca86858e33
- Timestamp:
- 03/01/07 18:52:11
(2 years ago)
- Author:
- Rémi Denis-Courmont <rem@videolan.org>
- git-committer:
- Rémi Denis-Courmont <rem@videolan.org> 1172771531 +0000
- git-parent:
[14c5e914ffb2ca51676a2d6c6b081a8e324fe47e]
- git-author:
- Rémi Denis-Courmont <rem@videolan.org> 1172771531 +0000
- Message:
Fix abortion if killing signals are re-used.
Of course, VLC has no bugs, so you never need to abort it that way,
so that this fixes nothing.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r65d2183 |
r1d58919 |
|
| 57 | 57 | #elif defined( PTHREAD_COND_T_IN_PTHREAD_H ) /* pthreads (like Linux & BSD) */ |
|---|
| 58 | 58 | # define LIBVLC_USE_PTHREAD 1 |
|---|
| | 59 | # define _APPLE_C_SOURCE 1 /* Proper pthread semantics on OSX */ |
|---|
| 59 | 60 | |
|---|
| 60 | 61 | # include <pthread.h> |
|---|
| reeb6783 |
r1d58919 |
|
| 28 | 28 | #include "config.h" |
|---|
| 29 | 29 | |
|---|
| | 30 | #include <vlc/vlc.h> |
|---|
| 30 | 31 | #include <stdio.h> /* fprintf() */ |
|---|
| 31 | 32 | #include <stdlib.h> /* putenv(), strtol(), */ |
|---|
| 32 | | #ifdef HAVE_SIGNAL_H |
|---|
| 33 | | # include <signal.h> /* SIGHUP, SIGINT, SIGKILL */ |
|---|
| 34 | | #endif |
|---|
| 35 | | #ifdef HAVE_TIME_H |
|---|
| 36 | | # include <time.h> /* time() */ |
|---|
| 37 | | #endif |
|---|
| 38 | | #ifdef HAVE_PTHREAD_H |
|---|
| 39 | | # include <pthread.h> |
|---|
| 40 | | #endif |
|---|
| 41 | | |
|---|
| 42 | | #include <vlc/vlc.h> |
|---|
| 43 | | |
|---|
| | 33 | |
|---|
| | 34 | |
|---|
| | 35 | /***************************************************************************** |
|---|
| | 36 | * Local prototypes. |
|---|
| | 37 | *****************************************************************************/ |
|---|
| 44 | 38 | #ifdef WIN32 |
|---|
| 45 | 39 | #include <windows.h> |
|---|
| 46 | 40 | extern void __wgetmainargs(int *argc, wchar_t ***wargv, wchar_t ***wenviron, |
|---|
| 47 | 41 | int expand_wildcards, int *startupinfo); |
|---|
| 48 | | #endif |
|---|
| 49 | | |
|---|
| 50 | | /***************************************************************************** |
|---|
| 51 | | * Local prototypes. |
|---|
| 52 | | *****************************************************************************/ |
|---|
| 53 | | #if !defined(WIN32) && !defined(UNDER_CE) |
|---|
| 54 | | static void *SigHandler ( void *set ); |
|---|
| | 42 | #else |
|---|
| | 43 | |
|---|
| | 44 | # include <signal.h> |
|---|
| | 45 | # include <time.h> |
|---|
| | 46 | # include <pthread.h> |
|---|
| | 47 | # include <stdbool.h> |
|---|
| | 48 | |
|---|
| | 49 | static struct |
|---|
| | 50 | { |
|---|
| | 51 | bool flag; |
|---|
| | 52 | pthread_mutex_t lock; |
|---|
| | 53 | } live = { true, PTHREAD_MUTEX_INITIALIZER }; |
|---|
| | 54 | |
|---|
| | 55 | static void *SigHandler (void *set); |
|---|
| 55 | 56 | #endif |
|---|
| 56 | 57 | |
|---|
| … | … | |
| 172 | 173 | i_ret = VLC_AddIntf( 0, NULL, VLC_TRUE, VLC_TRUE ); |
|---|
| 173 | 174 | |
|---|
| | 175 | /* Finish the threads */ |
|---|
| | 176 | VLC_CleanUp( 0 ); |
|---|
| | 177 | |
|---|
| | 178 | /* Destroy the libvlc structure */ |
|---|
| | 179 | VLC_Destroy( 0 ); |
|---|
| | 180 | |
|---|
| 174 | 181 | #if !defined(WIN32) && !defined(UNDER_CE) |
|---|
| 175 | 182 | pthread_cancel (sigth); |
|---|
| 176 | 183 | pthread_join (sigth, NULL); |
|---|
| 177 | 184 | #endif |
|---|
| 178 | | |
|---|
| 179 | | /* Finish the threads */ |
|---|
| 180 | | VLC_CleanUp( 0 ); |
|---|
| 181 | | |
|---|
| 182 | | /* Destroy the libvlc structure */ |
|---|
| 183 | | VLC_Destroy( 0 ); |
|---|
| 184 | 185 | |
|---|
| 185 | 186 | return i_ret; |
|---|
| … | … | |
| 193 | 194 | * It tries to end the program in a clean way. |
|---|
| 194 | 195 | *****************************************************************************/ |
|---|
| 195 | | static void *SigHandler( void *data ) |
|---|
| | 196 | static void *SigHandler (void *data) |
|---|
| 196 | 197 | { |
|---|
| 197 | 198 | const sigset_t *set = (sigset_t *)data; |
|---|
| … | … | |
| 209 | 210 | |
|---|
| 210 | 211 | pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &state); |
|---|
| 211 | | if( !b_die ) |
|---|
| | 212 | if (!b_die) |
|---|
| 212 | 213 | { |
|---|
| 213 | 214 | b_die = VLC_TRUE; |
|---|
| 214 | | abort_time = time( NULL ); |
|---|
| 215 | | |
|---|
| 216 | | fprintf( stderr, "signal %d received, terminating vlc - do it " |
|---|
| 217 | | "again in case it gets stuck\n", i_signal ); |
|---|
| | 215 | abort_time = time (NULL); |
|---|
| | 216 | |
|---|
| | 217 | fprintf (stderr, "signal %d received, terminating vlc - do it " |
|---|
| | 218 | "again in case it gets stuck\n", i_signal); |
|---|
| 218 | 219 | |
|---|
| 219 | 220 | /* Acknowledge the signal received */ |
|---|
| 220 | | VLC_Die( 0 ); |
|---|
| | 221 | pthread_mutex_lock (&live.lock); |
|---|
| | 222 | if (live.flag) |
|---|
| | 223 | { |
|---|
| | 224 | VLC_Die (0); |
|---|
| | 225 | live.flag = false; |
|---|
| | 226 | } |
|---|
| | 227 | pthread_mutex_unlock (&live.lock); |
|---|
| 221 | 228 | } |
|---|
| 222 | 229 | else if( time( NULL ) > abort_time + 2 ) |
|---|
| … | … | |
| 224 | 231 | /* If user asks again 1 or 2 seconds later, die badly */ |
|---|
| 225 | 232 | pthread_sigmask (SIG_UNBLOCK, set, NULL); |
|---|
| 226 | | fprintf( stderr, "user insisted too much, dying badly\n" ); |
|---|
| 227 | | abort(); |
|---|
| | 233 | fprintf (stderr, "user insisted too much, dying badly\n"); |
|---|
| | 234 | abort (); |
|---|
| 228 | 235 | } |
|---|
| 229 | 236 | pthread_setcancelstate (state, NULL); |
|---|