From: Nadav Har'El <[email protected]>
Committer: Nadav Har'El <[email protected]>
Branch: master
tests/tst-kill: fix hang on Linux
The test for interrupted system call used signal(), but on Linux this
function always restarts interrupted system calls - also blocking
network system calls - so this test would hang on Linux. So fix it to
use sigaction(), which properly interrupts the system call on both Linux
and OSv.
Signed-off-by: Nadav Har'El <[email protected]>
Message-Id: <[email protected]>
---
diff --git a/tests/tst-kill.cc b/tests/tst-kill.cc
--- a/tests/tst-kill.cc
+++ b/tests/tst-kill.cc
@@ -78,8 +78,16 @@ int main(int ac, char** av)
report(global == 0, "1 more second after cancelling alarm - still
global==0");
//Test that SIG_ALRM interrupts system calls
- sr = signal(SIGALRM, handler1);
- report(sr != SIG_ERR, "set SIGALRM handler");
+ // TODO: a previous version of this test used signal(), but on Linux
+ // signal() restarts system calls, so this test would fail, so we need
+ // to use sigaction() here. We should add a test verifying that on OSv
+ // signal() also doesn't interrupt networking system calls (however,
+ // currently such a test would fail).
+ //sr = signal(SIGALRM, handler1);
+ struct sigaction a = {};
+ a.sa_handler = handler1;
+ r = sigaction(SIGALRM, &a, nullptr);
+ report(r == 0, "set SIGALRM handler");
auto s = socket(AF_INET,SOCK_DGRAM,0);
char buf[10];
--
You received this message because you are subscribed to the Google Groups "OSv
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.