shithub: tlsclient

Download patch

ref: 02a90877ad29b7f1037ea577bee828a2f259a7e1
parent: eb53756615dfd7d4f6110ba3315de086780d977e
author: Jacob Moody <moody@posixcafe.org>
date: Tue Jul 5 17:50:18 EDT 2022

exit cleanly

--- a/cpu.c
+++ b/cpu.c
@@ -79,6 +79,12 @@
 }
 
 void
+suicide(int)
+{
+	exit(0);
+}
+
+void
 usage(void)
 {
 	fprint(2, "Usage: %s [ -R ] [ -u user ] [ -h host ] [ -a authserver ] -p port cmd...\n", argv0);
@@ -177,6 +183,9 @@
 		tls_send(-1, buf, i);
 	}
 
+	//clean exit
+	signal(SIGUSR1, suicide);
+
 	switch((xferc = fork())){
 	case -1:
 		sysfatal("fork");
@@ -188,9 +197,8 @@
 		xfer(-1, outfd, tls_recv, s_send);
 		break;
 	}
-	
-	if(xferc)
-		kill(xferc, SIGTERM);
+	kill(xferc, SIGUSR1);
+
 	if(execc)
 		kill(execc, SIGTERM);
 }