summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2024-07-12 07:15:29 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2024-07-12 07:15:29 +0000
commit2d07d9f175183e1bb13a2336931021b024b1f5d1 (patch)
treeebbfde4ad681417c6c8599e9e5a6fccc0bd9cb72 /usr.bin
parent89f23f06120751b07b4bf4d4807a041a112914ea (diff)
use sigaction() to setup SIGARLM so we can set SA_RESTART, and
remove the re-arming in the handler. Better than using siginterrupt(), and avoids the errno saving requirement in the handler also. ok guenther millert
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/openssl/speed.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/usr.bin/openssl/speed.c b/usr.bin/openssl/speed.c
index f1916efe1c0..08d19c9795e 100644
--- a/usr.bin/openssl/speed.c
+++ b/usr.bin/openssl/speed.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: speed.c,v 1.37 2024/07/09 11:21:44 deraadt Exp $ */
+/* $OpenBSD: speed.c,v 1.38 2024/07/12 07:15:28 deraadt Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -193,10 +193,6 @@ static void sig_done(int sig);
static void
sig_done(int sig)
{
- int save_errno = errno;
-
- signal(SIGALRM, sig_done);
- errno = save_errno;
run = 0;
}
@@ -436,6 +432,7 @@ speed_main(int argc, char **argv)
int decrypt = 0;
int multi = 0;
const char *errstr = NULL;
+ struct sigaction sa;
if (pledge("stdio proc", NULL) == -1) {
perror("pledge");
@@ -935,7 +932,12 @@ speed_main(int argc, char **argv)
memset(rsa_c, 0, sizeof(rsa_c));
#define COND(c) (run && count<0x7fffffff)
#define COUNT(d) (count)
- signal(SIGALRM, sig_done);
+
+ memset(&sa, 0, sizeof(sa));
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = SA_RESTART;
+ sa.sa_handler = sig_done;
+ sigaction(SIGALRM, &sa, NULL);
#ifndef OPENSSL_NO_MD4
if (doit[D_MD4]) {