summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-05-26 08:33:44 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-05-26 08:33:44 +0000
commit2d23eacfb96e718574049adea800257e0b39067e (patch)
tree83b2f96d2c46a9366d08e60f84888a2d4d4c47d3 /lib/libc
parent637bb72c923267f485c490f395cf06fe32574c30 (diff)
signal mask repair, netbsd pr#2442
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/getpass.c15
-rw-r--r--lib/libc/gen/sleep.c13
2 files changed, 14 insertions, 14 deletions
diff --git a/lib/libc/gen/getpass.c b/lib/libc/gen/getpass.c
index baf008f2eb8..375bfb9d785 100644
--- a/lib/libc/gen/getpass.c
+++ b/lib/libc/gen/getpass.c
@@ -1,4 +1,4 @@
-/* $NetBSD: getpass.c,v 1.7 1995/06/16 07:20:35 jtc Exp $ */
+/* $NetBSD: getpass.c,v 1.9 1996/05/20 06:13:07 jtc Exp $ */
/*
* Copyright (c) 1988, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)getpass.c 8.1 (Berkeley) 6/4/93";
#else
-static char rcsid[] = "$NetBSD: getpass.c,v 1.7 1995/06/16 07:20:35 jtc Exp $";
+static char rcsid[] = "$NetBSD: getpass.c,v 1.9 1996/05/20 06:13:07 jtc Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -57,9 +57,9 @@ getpass(prompt)
register int ch;
register char *p;
FILE *fp, *outfp;
- long omask;
int echo;
static char buf[_PASSWORD_LEN + 1];
+ sigset_t oset, nset;
/*
* read and write to /dev/tty if possible; else read from
@@ -69,11 +69,16 @@ getpass(prompt)
outfp = stderr;
fp = stdin;
}
+
/*
* note - blocking signals isn't necessarily the
* right thing, but we leave it for now.
*/
- omask = sigblock(sigmask(SIGINT)|sigmask(SIGTSTP));
+ sigemptyset(&nset);
+ sigaddset(&nset, SIGINT);
+ sigaddset(&nset, SIGTSTP);
+ (void)sigprocmask(SIG_BLOCK, &nset, &oset);
+
(void)tcgetattr(fileno(fp), &term);
if (echo = (term.c_lflag & ECHO)) {
term.c_lflag &= ~ECHO;
@@ -90,7 +95,7 @@ getpass(prompt)
term.c_lflag |= ECHO;
(void)tcsetattr(fileno(fp), TCSAFLUSH|TCSASOFT, &term);
}
- (void)sigsetmask(omask);
+ (void)sigprocmask(SIG_SETMASK, &oset, NULL);
if (fp != stdin)
(void)fclose(fp);
return(buf);
diff --git a/lib/libc/gen/sleep.c b/lib/libc/gen/sleep.c
index cba9c97b2e1..f369d54159e 100644
--- a/lib/libc/gen/sleep.c
+++ b/lib/libc/gen/sleep.c
@@ -104,12 +104,7 @@ sleep(seconds)
ringring = 0;
(void) sigsuspend(&set);
- if (ringring) {
- /* Our alarm went off; timer is not currently running */
- sigaction(SIGALRM, &oact, NULL);
- sigprocmask(SIG_SETMASK, &oset, NULL);
- (void) setitimer(ITIMER_REAL, &oitv, &itv);
- } else {
+ if (!ringring) {
struct itimerval nulltv;
/*
* Interrupted by other signal; allow for pending
@@ -119,10 +114,10 @@ sleep(seconds)
timerclear(&nulltv.it_interval);
timerclear(&nulltv.it_value);
(void) setitimer(ITIMER_REAL, &nulltv, &itv);
- sigprocmask(SIG_SETMASK, &oset, NULL);
- sigaction(SIGALRM, &oact, NULL);
- (void) setitimer(ITIMER_REAL, &oitv, NULL);
}
+ sigprocmask(SIG_SETMASK, &oset, NULL);
+ sigaction(SIGALRM, &oact, NULL);
+ (void) setitimer(ITIMER_REAL, &oitv, &itv);
if (timerisset(&diff))
timeradd(&itv.it_value, &diff, &itv.it_value);