Skip to content

Commit 71521d1

Browse files
committed
Don't close channels when a PID hasn't started
If check_close() ran prior to a server channel exec/shell request, it would send a close immediately. This fix changes it to exclude write_fd==FD_UNINIT from being closed there. When a channel was closed by the time shell/exec request was received, then data sent hits an assertion. This fixes #321 on Github. The "pid == 0" check was initially added to avoid waiting to close a channel when a process has never been launched (which is correct), but that isn't correct in the case of the closed-fd test. Fixes: 8e6f73e ("- Remove "flushing" handling for exited processes)
1 parent 588072a commit 71521d1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/common-channel.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@ static void check_close(struct Channel *channel) {
317317

318318
if ((channel->recv_eof && !write_pending(channel))
319319
/* have a server "session" and child has exited */
320-
|| (channel->type->check_close && close_allowed)) {
320+
|| (channel->writefd != FD_UNINIT
321+
&& channel->type->check_close && close_allowed)) {
321322
close_chan_fd(channel, channel->writefd, SHUT_WR);
322323
}
323324

0 commit comments

Comments
 (0)