diff options
author | Mike Frysinger <vapier@gentoo.org> | 2009-10-28 01:47:50 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2009-10-28 01:59:00 -0400 |
commit | b076b4e700b1553c2468b0cc62abcb51a4c53f3e (patch) | |
tree | df2ae25ff80d7a9e6a70802e35da2112a12a71a3 | |
parent | sandbox: dont warn about inherited ignored signals (diff) | |
download | sandbox-b076b4e700b1553c2468b0cc62abcb51a4c53f3e.tar.gz sandbox-b076b4e700b1553c2468b0cc62abcb51a4c53f3e.tar.bz2 sandbox-b076b4e700b1553c2468b0cc62abcb51a4c53f3e.zip |
tests: make signal code a bit more flexible
This lets us easily set default signal handlers and execute code.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rw-r--r-- | tests/signal_static-0.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/tests/signal_static-0.c b/tests/signal_static-0.c index e50e1dc..390e8f5 100644 --- a/tests/signal_static-0.c +++ b/tests/signal_static-0.c @@ -8,6 +8,27 @@ int main(int argc, char *argv[]) * for possible skip status */ return 0; - else - return kill(getpid(), lookup_signal(argv[1])); + + char pre = argv[1][0]; + int sig; + switch (pre) { + case '+': + case '-': + ++argv[1]; + default: + sig = lookup_signal(argv[1]); + } + + int ret; + switch (pre) { + case '+': ret = (signal(sig, SIG_DFL) == SIG_ERR); break; + case '-': ret = (signal(sig, SIG_IGN) == SIG_ERR); break; + default: ret = kill(getpid(), sig); break; + } + + if (argc > 2) { + argv += 2; + return execv(argv[0], argv); + } else + return ret; } |