From a86c633c2bffd1e4acc6298222faa6c343f21e89 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Fri, 15 Sep 2017 22:06:02 +1000 Subject: [PATCH] More fiddling with ssh --- bbs.c | 12 +++++++++--- main.c | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/bbs.c b/bbs.c index ffc7848..feb8a61 100644 --- a/bbs.c +++ b/bbs.c @@ -461,14 +461,19 @@ void s_readpass(char *buffer, int max) { } } +void exit_bbs() { + char buffer[1024]; + snprintf(buffer, 1024, "%s/nodeinuse.%d", conf.bbs_path, mynode); + remove(buffer); +} + void disconnect(char *calledby) { - char buffer[1024]; + if (gUser != NULL) { save_user(gUser); } dolog("Node %d disconnected (%s)", mynode, calledby); - sprintf(buffer, "%s/nodeinuse.%d", conf.bbs_path, mynode); - remove(buffer); + if (!sshBBS) { close(gSocket); } @@ -651,6 +656,7 @@ void runbbs_real(int socket, char *ip, int ssh) { int usernotfound; int tries; + atexit(exit_bbs); ipaddress = ip; diff --git a/main.c b/main.c index 698838d..b2ef55a 100644 --- a/main.c +++ b/main.c @@ -661,7 +661,7 @@ static void ssh_chan_close(ssh_session session, ssh_channel channel, void *userd (void)session; (void)channel; kill(bbs_pid, SIGTERM); - //waitpid(bbs_pid, &status, 0); + waitpid(bbs_pid, &status, 0); close(fd); }