comparison 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
comparison
equal deleted inserted replaced
1827:8a78cc13eb30 1828:3f0ac6bc58a1
74 }; 74 };
75 75
76 /* required to clear environment */ 76 /* required to clear environment */
77 extern char** environ; 77 extern char** environ;
78 78
79 /* Returns whether the channel is ready to close. The child process
80 must not be running (has never started, or has exited) */
79 static int sesscheckclose(const struct Channel *channel) { 81 static int sesscheckclose(const struct Channel *channel) {
80 struct ChanSess *chansess = (struct ChanSess*)channel->typedata; 82 struct ChanSess *chansess = (struct ChanSess*)channel->typedata;
81 TRACE(("sesscheckclose, pid is %d", chansess->exit.exitpid)) 83 TRACE(("sesscheckclose, pid %d, exitpid %d", chansess->pid, chansess->exit.exitpid))
82 return chansess->exit.exitpid != -1; 84 return chansess->pid == 0 || chansess->exit.exitpid != -1;
83 } 85 }
84 86
85 /* Handler for childs exiting, store the state for return to the client */ 87 /* Handler for childs exiting, store the state for return to the client */
86 88
87 /* There's a particular race we have to watch out for: if the forked child 89 /* There's a particular race we have to watch out for: if the forked child