diff svr-chansession.c @ 1828:3f0ac6bc58a1

- Remove "flushing" handling for exited processes, it should be handled by normal file descriptor reads. - Fix sesscheckclose() handling if a channel was closed before a process was ever launched
author Matt Johnston <matt@ucc.asn.au>
date Mon, 11 Oct 2021 15:16:54 +0800
parents eaa2d7240a5d
children a7cc3332d8ab
line wrap: on
line diff
--- a/svr-chansession.c	Mon Oct 11 15:14:46 2021 +0800
+++ b/svr-chansession.c	Mon Oct 11 15:16:54 2021 +0800
@@ -76,10 +76,12 @@
 /* required to clear environment */
 extern char** environ;
 
+/* Returns whether the channel is ready to close. The child process
+   must not be running (has never started, or has exited) */
 static int sesscheckclose(const struct Channel *channel) {
 	struct ChanSess *chansess = (struct ChanSess*)channel->typedata;
-	TRACE(("sesscheckclose, pid is %d", chansess->exit.exitpid))
-	return chansess->exit.exitpid != -1;
+	TRACE(("sesscheckclose, pid %d, exitpid %d", chansess->pid, chansess->exit.exitpid))
+	return chansess->pid == 0 || chansess->exit.exitpid != -1;
 }
 
 /* Handler for childs exiting, store the state for return to the client */