comparison common-channel.c @ 1835:90ac15aeac43

Bring back recently removed channel->flushing This resolves the "sleep 10&echo hello" case which should return immediately
author Matt Johnston <matt@codeconstruct.com.au>
date Thu, 14 Oct 2021 20:55:15 +0800
parents a7cc3332d8ab
children 1d86a58fb52d
comparison
equal deleted inserted replaced
1834:94dc11094e26 1835:90ac15aeac43
283 channel->writebuf ? cbuf_getused(channel->writebuf) : 0, 283 channel->writebuf ? cbuf_getused(channel->writebuf) : 0,
284 channel->extrabuf ? cbuf_getused(channel->extrabuf) : 0)) 284 channel->extrabuf ? cbuf_getused(channel->extrabuf) : 0))
285 285
286 /* if a type-specific check_close is defined we will only exit 286 /* if a type-specific check_close is defined we will only exit
287 once that has been triggered. this is only used for a server "session" 287 once that has been triggered. this is only used for a server "session"
288 channel, to ensure that the shell has exited (and the exit status 288 channel, to ensure that the shell has exited (and the exit status
289 retrieved) before we close things up. */ 289 retrieved) before we close things up. */
290 if (!channel->type->check_close 290 if (!channel->type->check_close
291 || channel->sent_close 291 || channel->sent_close
292 || channel->type->check_close(channel)) { 292 || channel->type->check_close(channel)) {
293 close_allowed = 1; 293 close_allowed = 1;
294 }
295
296 /* In flushing mode we close FDs as soon as pipes are empty.
297 This is used to drain out FDs when the process exits, in the case
298 where the FD doesn't have EOF - "sleep 10&echo hello" case */
299 if (channel->flushing) {
300 if (channel->readfd >= 0 && !fd_read_pending(channel->readfd)) {
301 close_chan_fd(channel, channel->readfd, SHUT_RD);
302 }
303 if (ERRFD_IS_READ(channel)
304 && channel->errfd >= 0 && !fd_read_pending(channel->errfd)) {
305 close_chan_fd(channel, channel->errfd, SHUT_RD);
306 }
294 } 307 }
295 308
296 if (channel->recv_close && !write_pending(channel) && close_allowed) { 309 if (channel->recv_close && !write_pending(channel) && close_allowed) {
297 if (!channel->sent_close) { 310 if (!channel->sent_close) {
298 TRACE(("Sending MSG_CHANNEL_CLOSE in response to same.")) 311 TRACE(("Sending MSG_CHANNEL_CLOSE in response to same."))