Changeset c6b6537f4d82d799bb4ee6d4c8c1dc6b87c0542c
- Timestamp:
- 12/12/07 20:47:39
(9 months ago)
- Author:
- Rémi Denis-Courmont <rem@videolan.org>
- git-committer:
- Rémi Denis-Courmont <rem@videolan.org> 1197488859 +0000
- git-parent:
[6c62642f455bfabd4a8c63fa6af0ee0d913ad703]
- git-author:
- Rémi Denis-Courmont <rem@videolan.org> 1197488859 +0000
- Message:
Clear signal mask _between_ fork() and exec*().
Before fork() would break VLC's own sigmask.
After exec*() would rely on the children program to do it (and many don't).
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rb8acb75 |
rc6b6537 |
|
| 135 | 135 | static void Execute( intf_thread_t *p_this, const char *const *ppsz_args ) |
|---|
| 136 | 136 | { |
|---|
| 137 | | pid_t pid; |
|---|
| 138 | | switch( pid = fork() ) |
|---|
| | 137 | pid_t pid = fork(); |
|---|
| | 138 | switch( pid ) |
|---|
| 139 | 139 | { |
|---|
| 140 | 140 | case 0: /* we're the child */ |
|---|
| | 141 | { |
|---|
| | 142 | sigset_t set; |
|---|
| | 143 | sigemptyset (&set); |
|---|
| | 144 | pthread_sigmask (SIG_SETMASK, &set, NULL); |
|---|
| | 145 | |
|---|
| 141 | 146 | /* We don't want output */ |
|---|
| 142 | 147 | freopen( "/dev/null", "w", stdout ); |
|---|
| … | … | |
| 144 | 149 | execv( ppsz_args[0] , (char *const *)ppsz_args ); |
|---|
| 145 | 150 | /* If the file we want to execute doesn't exist we exit() */ |
|---|
| 146 | | exit( 1 ); |
|---|
| 147 | | break; |
|---|
| | 151 | exit( EXIT_FAILURE ); |
|---|
| | 152 | } |
|---|
| 148 | 153 | case -1: /* we're the error */ |
|---|
| 149 | 154 | msg_Dbg( p_this, "Couldn't fork() while launching %s", |
|---|
| r2578127 |
rc6b6537 |
|
| 954 | 954 | |
|---|
| 955 | 955 | case 0: |
|---|
| | 956 | { |
|---|
| | 957 | sigset_t set; |
|---|
| | 958 | sigemptyset (&set); |
|---|
| | 959 | pthread_sigmask (SIG_SETMASK, &set, NULL); |
|---|
| | 960 | |
|---|
| 956 | 961 | /* NOTE: |
|---|
| 957 | 962 | * Like it or not, close can fail (and not only with EBADF) |
|---|
| … | … | |
| 963 | 968 | execve (ppsz_argv[0], ppsz_argv, ppsz_env); |
|---|
| 964 | 969 | |
|---|
| 965 | | exit (1); |
|---|
| | 970 | exit (EXIT_FAILURE); |
|---|
| | 971 | } |
|---|
| 966 | 972 | } |
|---|
| 967 | 973 | |
|---|