From 781761390541b469c0b2b93f0f1c7bb73dd19ecd Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Thu, 25 Jan 2001 08:06:34 +0000 Subject: call _exit() in signal handler --- usr.bin/ssh/ssh-agent.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/ssh/ssh-agent.c b/usr.bin/ssh/ssh-agent.c index d1739e273f9..9eb1615c614 100644 --- a/usr.bin/ssh/ssh-agent.c +++ b/usr.bin/ssh/ssh-agent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-agent.c,v 1.47 2001/01/21 19:05:56 markus Exp $ */ +/* $OpenBSD: ssh-agent.c,v 1.48 2001/01/25 08:06:33 deraadt Exp $ */ /* * Author: Tatu Ylonen @@ -37,7 +37,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: ssh-agent.c,v 1.47 2001/01/21 19:05:56 markus Exp $"); +RCSID("$OpenBSD: ssh-agent.c,v 1.48 2001/01/25 08:06:33 deraadt Exp $"); #include #include @@ -679,8 +679,10 @@ check_parent_exists(int sig) void cleanup_socket(void) { - unlink(socket_name); - rmdir(socket_dir); + if (socket_name[0]) + unlink(socket_name); + if (socket_dir[0]) + rmdir(socket_dir); } void @@ -690,6 +692,13 @@ cleanup_exit(int i) exit(i); } +void +cleanup_handler(int sig) +{ + cleanup_socket(); + _exit(2); +} + void usage() { @@ -851,8 +860,8 @@ main(int ac, char **av) idtab_init(); signal(SIGINT, SIG_IGN); signal(SIGPIPE, SIG_IGN); - signal(SIGHUP, cleanup_exit); - signal(SIGTERM, cleanup_exit); + signal(SIGHUP, cleanup_handler); + signal(SIGTERM, cleanup_handler); while (1) { prepare_select(&readsetp, &writesetp, &max_fd); if (select(max_fd + 1, readsetp, writesetp, NULL, NULL) < 0) { -- cgit v1.2.3