commit 10f14b04f31487f02f9fa7ac8d7d633683edaa65 from: rsc date: Sun Jan 16 21:28:44 2005 UTC update return interface commit - 32053cdfb36ca6653bc2aad7a1962ab9692ae286 commit + 10f14b04f31487f02f9fa7ac8d7d633683edaa65 blob - 2528ee989ab3b478d1bea22cf490294c0acf5283 blob + 653606a16034166f749c87b342b9d3ff787902da --- include/libc.h +++ include/libc.h @@ -722,10 +722,10 @@ extern int unmount(char*, char*); */ extern int noted(int); extern int notify(void(*)(void*, char*)); -extern void noteenable(char*); -extern void notedisable(char*); -extern void notifyon(char*); -extern void notifyoff(char*); +extern int noteenable(char*); +extern int notedisable(char*); +extern int notifyon(char*); +extern int notifyoff(char*); extern int p9open(char*, int); extern int fd2path(int, char*, int); extern int p9pipe(int*); blob - 364181ca9b287359f4a4caa7f9e6c48da0793cf6 blob + c4675be10e092c1247691030930bcce12c31dd33 --- src/lib9/notify.c +++ src/lib9/notify.c @@ -36,6 +36,13 @@ struct Sig int notified; /* do we call the notify function for this signal? */ }; +/* + * Bug. It is profoundly anti-social to play with the masks like this. + * For example, even though we don't want to see SIGTSTP, others do. + * Running bash inside a 9term that has disabled SIGTSTP makes ^Z not work. + * Instead we need to leave the signals enabled but notifyoff them. + */ + /* initial settings; for current status, ask the kernel */ static Sig sigs[] = { SIGHUP, 0, 1, 1, @@ -172,40 +179,41 @@ handler(int s) return sa.sa_handler; } -static void +static int notesetenable(int sig, int enabled) { - sigset_t mask; + sigset_t mask, omask; if(sig == 0) - return; + return -1; sigemptyset(&mask); sigaddset(&mask, sig); - sigprocmask(enabled ? SIG_UNBLOCK : SIG_BLOCK, &mask, nil); + sigprocmask(enabled ? SIG_UNBLOCK : SIG_BLOCK, &mask, &omask); + return !sigismember(&omask, sig); } -void +int noteenable(char *msg) { - notesetenable(_p9strsig(msg), 1); + return notesetenable(_p9strsig(msg), 1); } -void +int notedisable(char *msg) { - notesetenable(_p9strsig(msg), 0); + return notesetenable(_p9strsig(msg), 0); } -static void +static int notifyseton(int s, int on) { Sig *sig; - struct sigaction sa; + struct sigaction sa, osa; sig = findsig(s); if(sig == nil) - return; + return -1; memset(&sa, 0, sizeof sa); sa.sa_handler = on ? signotify : signonotify; if(sig->restart) @@ -220,19 +228,20 @@ notifyseton(int s, int on) /* * Install handler. */ - sigaction(sig->sig, &sa, nil); + sigaction(sig->sig, &sa, &osa); + return osa.sa_handler == signotify; } -void +int notifyon(char *msg) { - notifyseton(_p9strsig(msg), 1); + return notifyseton(_p9strsig(msg), 1); } -void +int notifyoff(char *msg) { - notifyseton(_p9strsig(msg), 0); + return notifyseton(_p9strsig(msg), 0); } /*