@@ -54,7 +54,7 @@ pub fn validate_vcpu_signal_num(num: c_int) -> io::Result<c_int> {
54
54
///
55
55
/// This is considered unsafe because the given handler will be called asynchronously, interrupting
56
56
/// whatever the thread was doing and therefore must only do async-signal-safe operations.
57
- pub unsafe fn register_vcpu_signal_handler ( num : i32 , handler : SignalHandler ) -> io:: Result < ( ) > {
57
+ pub unsafe fn register_vcpu_signal_handler ( num : c_int , handler : SignalHandler ) -> io:: Result < ( ) > {
58
58
let num = validate_vcpu_signal_num ( num) ?;
59
59
// Safe, because this is a POD struct.
60
60
let mut sigact: sigaction = mem:: zeroed ( ) ;
@@ -64,11 +64,11 @@ pub unsafe fn register_vcpu_signal_handler(num: i32, handler: SignalHandler) ->
64
64
}
65
65
66
66
/// Registers the specified signal handler for `SIGSYS`.
67
- pub fn register_sigsys_handler ( sigsys_handler : SignalHandler ) -> Result < ( ) , io:: Error > {
67
+ pub fn register_signal_handler ( signum : c_int , handler : SignalHandler ) -> Result < ( ) , io:: Error > {
68
68
// Safe, because this is a POD struct.
69
69
let mut sigact: sigaction = unsafe { mem:: zeroed ( ) } ;
70
70
sigact. sa_flags = libc:: SA_SIGINFO ;
71
- sigact. sa_sigaction = sigsys_handler as usize ;
71
+ sigact. sa_sigaction = handler as usize ;
72
72
73
73
// We set all the bits of sa_mask, so all signals are blocked on the current thread while the
74
74
// SIGSYS handler is executing. Safe because the parameter is valid and we check the return
@@ -78,7 +78,7 @@ pub fn register_sigsys_handler(sigsys_handler: SignalHandler) -> Result<(), io::
78
78
}
79
79
80
80
// Safe because the parameters are valid and we check the return value.
81
- unsafe { SyscallReturnCode ( sigaction ( libc :: SIGSYS , & sigact, null_mut ( ) ) ) . into_empty_result ( ) }
81
+ unsafe { SyscallReturnCode ( sigaction ( signum , & sigact, null_mut ( ) ) ) . into_empty_result ( ) }
82
82
}
83
83
84
84
/// Trait for threads that can be signalled via `pthread_kill`.
@@ -116,6 +116,8 @@ mod tests {
116
116
use std:: thread;
117
117
use std:: time:: Duration ;
118
118
119
+ use libc:: SIGSYS ;
120
+
119
121
static mut SIGNAL_HANDLER_CALLED : bool = false ;
120
122
121
123
extern "C" fn handle_signal ( _: c_int , _: * mut siginfo_t , _: * mut c_void ) {
@@ -130,7 +132,7 @@ mod tests {
130
132
// testing bad value
131
133
assert ! ( register_vcpu_signal_handler( SIGRTMAX ( ) , handle_signal) . is_err( ) ) ;
132
134
assert ! ( register_vcpu_signal_handler( 0 , handle_signal) . is_ok( ) ) ;
133
- assert ! ( register_sigsys_handler ( handle_signal) . is_ok( ) ) ;
135
+ assert ! ( register_signal_handler ( SIGSYS , handle_signal) . is_ok( ) ) ;
134
136
}
135
137
}
136
138
0 commit comments