aboutsummaryrefslogtreecommitdiff
path: root/src/lib9/notify.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-12-26 21:51:15 +0000
committerrsc <devnull@localhost>2004-12-26 21:51:15 +0000
commit5f8fa94796903bf81db4f1dc76d433a80308b3d4 (patch)
treebc94c36965c4bf6cdb420c4c5fe628024647f88e /src/lib9/notify.c
parentb2ff5382580e13d82ca48966c9d79d3318865cba (diff)
downloadplan9port-5f8fa94796903bf81db4f1dc76d433a80308b3d4.tar.gz
plan9port-5f8fa94796903bf81db4f1dc76d433a80308b3d4.tar.bz2
plan9port-5f8fa94796903bf81db4f1dc76d433a80308b3d4.zip
cleanups - lots of removed files now in thread library.
qlock.c - stubs to thread library notify.c - clean interface slightly.
Diffstat (limited to 'src/lib9/notify.c')
-rw-r--r--src/lib9/notify.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/lib9/notify.c b/src/lib9/notify.c
index 2b95e099..faf13928 100644
--- a/src/lib9/notify.c
+++ b/src/lib9/notify.c
@@ -7,9 +7,9 @@
* There is no equivalent note to Unix's SIGKILL, since
* it's not a deliverable signal anyway.
*
- * We do not handle SIGABRT or SIGSEGV, mainly so that
- * stack traces show the original source of the signal instead
- * of notifysigf.
+ * We do not handle SIGABRT or SIGSEGV, mainly because
+ * the thread library queues its notes for later, and we want
+ * to dump core with the state at time of delivery.
*
* We have to add some extra entry points to provide the
* ability to tweak which signals are deliverable and which
@@ -112,7 +112,6 @@ static void (*notifyf)(void*, char*); /* Plan 9 handler */
static void
signotify(int sig)
{
- int v;
char tmp[64];
Jmp *j;
@@ -150,7 +149,6 @@ noted(int v)
int
notify(void (*f)(void*, char*))
{
- int i;
static int init;
notifyf = f;
@@ -164,7 +162,8 @@ notify(void (*f)(void*, char*))
/*
* Nonsense about enabling and disabling signals.
*/
-static void(*)(int)
+typedef void Sighandler(int);
+static Sighandler*
handler(int s)
{
struct sigaction sa;
@@ -174,7 +173,7 @@ handler(int s)
}
static void
-notifysetenable(int sig, int enabled)
+notesetenable(int sig, int enabled)
{
sigset_t mask;
@@ -187,15 +186,15 @@ notifysetenable(int sig, int enabled)
}
void
-notifyenable(char *msg)
+noteenable(char *msg)
{
- notifyenablex(_p9strsig(msg), 1);
+ notesetenable(_p9strsig(msg), 1);
}
void
-notifydisable(char *msg)
+notedisable(char *msg)
{
- notifyenablex(_p9strsig(msg), 0);
+ notesetenable(_p9strsig(msg), 0);
}
static void
@@ -207,7 +206,8 @@ notifyseton(int s, int on)
sig = findsig(s);
if(sig == nil)
return;
- notifyenable(msg);
+ if(on)
+ notesetenable(s, 1);
memset(&sa, 0, sizeof sa);
sa.sa_handler = on ? signotify : signonotify;
if(sig->restart)
@@ -234,7 +234,7 @@ notifyon(char *msg)
void
notifyoff(char *msg)
{
- notifysetoff(_p9strsig(msg), 0);
+ notifyseton(_p9strsig(msg), 0);
}
/*
@@ -252,6 +252,7 @@ noteinit(void)
* If someone has already installed a handler,
* It's probably some ld preload nonsense,
* like pct (a SIGVTALRM-based profiler).
+ * Or maybe someone has already called notifyon/notifyoff.
* Leave it alone.
*/
if(handler(sig->sig) != SIG_DFL)
@@ -261,7 +262,7 @@ noteinit(void)
* (I.e. if parent has disabled for us, should we still enable?)
* Right now we always initialize to the state we want.
*/
- notifysetenable(sig->sig, sig->enabled);
+ notesetenable(sig->sig, sig->enabled);
notifyseton(sig->sig, sig->notified);
}
}