aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Seebach <seebs@eee12.(none)>2010-04-20 19:54:42 -0500
committerPeter Seebach <peter.seebach@windriver.com>2010-04-26 17:13:45 -0700
commit69de8f0dfdd47fb70487f0d8213e5659e9b7e2c6 (patch)
treedd2fd882927355fa9640adb6d32ff85520720b99
parentaceacb055724aae4c4e8822db19a8faf1943d9ef (diff)
downloadpseudo-69de8f0dfdd47fb70487f0d8213e5659e9b7e2c6.tar.gz
pseudo-69de8f0dfdd47fb70487f0d8213e5659e9b7e2c6.tar.bz2
pseudo-69de8f0dfdd47fb70487f0d8213e5659e9b7e2c6.zip
Avoid signalling during mutex operations.
remake(1) can try to close a file from a signal handler. Since any entrance to a pseudo-emulated function requires the mutex, this can result in a deadlock. Solution: Suspend SIGCHLD (and a couple of other signals likely to result in filesystem operations) for the duration of the lock.
-rwxr-xr-xmakewrappers14
-rw-r--r--pseudo_wrappers.c1
2 files changed, 15 insertions, 0 deletions
diff --git a/makewrappers b/makewrappers
index d269aa3..b0462fe 100755
--- a/makewrappers
+++ b/makewrappers
@@ -270,7 +270,19 @@ EOF
fi
# and now the body of the wrapper:
cat >&5 <<EOF
+ sigset_t blocked, saved;
+
pseudo_debug(4, "called: $name\n");
+ /* these are signals for which the handlers often
+ * invoke operations, such as close(), which are handled
+ * by pseudo and could result in a deadlock.
+ */
+ sigemptyset(&blocked);
+ sigaddset(&blocked, SIGCHLD);
+ sigaddset(&blocked, SIGALRM);
+ sigaddset(&blocked, SIGUSR1);
+ sigaddset(&blocked, SIGUSR2);
+ sigprocmask(SIG_BLOCK, &blocked, &saved);
if (pseudo_getlock()) {
errno = EBUSY;
sigprocmask(SIG_SETMASK, &saved, NULL);
@@ -293,11 +305,13 @@ $free_paths
}
save_errno = errno;
pseudo_droplock();
+ sigprocmask(SIG_SETMASK, &saved, NULL);
errno = save_errno;
pseudo_debug(4, "completed: $name\n");
$(write_return rc);
} else {
pseudo_droplock();
+ sigprocmask(SIG_SETMASK, &saved, NULL);
pseudo_debug(4, "completed: $name\n");
$(write_return "dummy_$name($argnames)");
}
diff --git a/pseudo_wrappers.c b/pseudo_wrappers.c
index fd864f1..2ea4a04 100644
--- a/pseudo_wrappers.c
+++ b/pseudo_wrappers.c
@@ -8,6 +8,7 @@
#include <string.h>
#include <errno.h>
#include <pthread.h>
+#include <signal.h>
#include <sys/types.h>
#include <unistd.h>