Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
f014cdaf
Commit
f014cdaf
authored
Apr 12, 2010
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve signal/sigaction wrapper
parent
6c948b6d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
9 deletions
+34
-9
bin/override.c
bin/override.c
+34
-9
No files found.
bin/override.c
View file @
f014cdaf
...
...
@@ -173,26 +173,51 @@ int rand (void)
/** Signals **/
#include <signal.h>
static
bool
blocked_signal
(
int
num
)
{
switch
(
num
)
{
case
SIGINT
:
case
SIGHUP
:
case
SIGQUIT
:
case
SIGTERM
:
case
SIGPIPE
:
case
SIGCHLD
:
return
true
;
}
return
false
;
}
void
(
*
signal
(
int
signum
,
void
(
*
handler
)
(
int
)))
(
int
)
{
if
(
override
)
{
const
char
*
msg
=
"Error"
;
if
((
signum
==
SIGPIPE
&&
handler
==
SIG_IGN
)
||
(
signum
!=
SIGPIPE
&&
handler
==
SIG_DFL
))
/* Same settings we already use */
msg
=
"Warning"
;
LOG
(
msg
,
"%d, %p"
,
signum
,
handler
);
if
(
handler
!=
SIG_IGN
&&
handler
!=
SIG_DFL
)
goto
error
;
if
(
!
blocked_signal
(
signum
))
goto
error
;
/* For our blocked signals, the handler won't matter much... */
LOG
(
"Warning"
,
"%d, %p"
,
signum
,
handler
);
}
return
CALL
(
signal
,
signum
,
handler
);
error:
LOG
(
"Blocked"
,
"%d, %p"
,
signum
,
handler
);
return
SIG_DFL
;
}
int
sigaction
(
int
signum
,
const
struct
sigaction
*
act
,
struct
sigaction
*
old
)
{
if
(
act
!=
NULL
)
LOG
(
"Error"
,
"%d, %p, %p"
,
signum
,
act
,
old
);
if
(
override
&&
act
!=
NULL
)
{
if
((
act
->
sa_flags
&
SA_SIGINFO
)
||
(
act
->
sa_handler
!=
SIG_IGN
&&
act
->
sa_handler
!=
SIG_DFL
))
goto
error
;
LOG
(
"Warning"
,
"%d, %p, %p"
,
signum
,
act
,
old
);
}
return
CALL
(
sigaction
,
signum
,
act
,
old
);
error:
LOG
(
"Blocked"
,
"%d, %p, %p"
,
signum
,
act
,
old
);
return
-
1
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment