Add SA_RESTART flag to signal handler
authorPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Tue, 7 Jul 2009 22:14:19 +0000 (18:14 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Tue, 7 Jul 2009 22:14:19 +0000 (18:14 -0400)
With this flag, the kernel restarts automatically some system calls
that were interrupted by the signal. Without this flag, these system
calls would fail with errno = EINTR.

Even with this flag, the kernel cannot restart some system calls, and
developers should verify whether these system calls failed with EINTR
and restart them manually in that case. For the list of system calls
that cannot be restarted automatically, see signal(7).

Because of this, we cannot completely eliminate the side-effects of
liburcu on the application, but I think we should try our best and
set SA_RESTART.

From: Pierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
README
urcu.c

diff --git a/README b/README
index 71cf729598bd8e5e9223246a3b5562bbaa017dd5..2fae654de9a0aac1bf4e5ea83eebb70656757283 100644 (file)
--- a/README
+++ b/README
@@ -29,6 +29,14 @@ Writing
        After, synchronize_rcu() must be called. When it returns, the old
        values are not in usage anymore.
 
+Being careful with signals
+
+       The library uses signals internally. The signal handler is
+       registered with the SA_RESTART flag. However, these signals may cause
+       some non-restartable system calls to fail with errno = EINTR. Care
+       should be taken to restart system calls manually if they fail with this
+       error. A list of non-restartable system calls may be found in
+       signal(7).
 
 Usage of DEBUG_FULL_MB
 
diff --git a/urcu.c b/urcu.c
index f219e7632f50d232cbb3f73c75b097f56246215f..51c279f3aa91e7731ce4016f88af4fa7cd7d0025 100644 (file)
--- a/urcu.c
+++ b/urcu.c
@@ -451,7 +451,7 @@ void urcu_init(void)
        init_done = 1;
 
        act.sa_sigaction = sigurcu_handler;
-       act.sa_flags = SA_SIGINFO;
+       act.sa_flags = SA_SIGINFO | SA_RESTART;
        sigemptyset(&act.sa_mask);
        ret = sigaction(SIGURCU, &act, NULL);
        if (ret) {
This page took 0.026854 seconds and 4 git commands to generate.