Skip to content
Snippets Groups Projects
Commit 2283e25c authored by Graham MacDonald's avatar Graham MacDonald
Browse files

sigaction should set sigaction.sa_restorer

parent cdbbd4a4
No related branches found
No related tags found
No related merge requests found
...@@ -89,6 +89,7 @@ pub unsafe extern "C" fn sigaction( ...@@ -89,6 +89,7 @@ pub unsafe extern "C" fn sigaction(
let act_opt = act.as_ref().map(|act| { let act_opt = act.as_ref().map(|act| {
let mut act_clone = act.clone(); let mut act_clone = act.clone();
act_clone.sa_flags |= SA_RESTORER as c_ulong; act_clone.sa_flags |= SA_RESTORER as c_ulong;
act_clone.sa_restorer = Some(__restore_rt);
act_clone act_clone
}); });
Sys::sigaction(sig, act_opt.as_ref(), oact.as_mut()) Sys::sigaction(sig, act_opt.as_ref(), oact.as_mut())
......
...@@ -23,6 +23,7 @@ EXPECT_NAMES=\ ...@@ -23,6 +23,7 @@ EXPECT_NAMES=\
regex \ regex \
select \ select \
setjmp \ setjmp \
sigaction \
signal \ signal \
stdio/all \ stdio/all \
stdio/buffer \ stdio/buffer \
......
Raising...
Signal handler1 called!
Raising...
Signal handler2 called!
Raised.
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include "test_helpers.h"
void handler1(int sig) {
ERROR_IF(handler, sig, != SIGUSR1);
puts("Signal handler1 called!");
}
void handler2(int sig) {
ERROR_IF(handler, sig, != SIGUSR1);
puts("Signal handler2 called!");
}
int main(void) {
struct sigaction sa1 = { .sa_handler = handler1 };
struct sigaction sa2 = { .sa_handler = handler2 };
struct sigaction saold = {0};
sigemptyset(&sa1.sa_mask);
sigemptyset(&sa2.sa_mask);
int rcode = sigaction(SIGUSR1, &sa1, NULL);
ERROR_IF(signal, rcode, != 0);
puts("Raising...");
int raise_status = raise(SIGUSR1);
ERROR_IF(raise, raise_status, < 0);
rcode = sigaction(SIGUSR1, &sa2, &saold);
ERROR_IF(signal, rcode, != 0);
ERROR_IF(signal, saold.sa_handler, != sa1.sa_handler);
puts("Raising...");
raise_status = raise(SIGUSR1);
ERROR_IF(raise, raise_status, < 0);
puts("Raised.");
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment