version 1.417, 2022/04/20 04:19:11 |
version 1.418, 2022/05/04 07:31:22 |
|
|
channel_register_fds(struct ssh *ssh, Channel *c, int rfd, int wfd, int efd, |
channel_register_fds(struct ssh *ssh, Channel *c, int rfd, int wfd, int efd, |
int extusage, int nonblock, int is_tty) |
int extusage, int nonblock, int is_tty) |
{ |
{ |
|
int val; |
|
|
if (rfd != -1) |
if (rfd != -1) |
fcntl(rfd, F_SETFD, FD_CLOEXEC); |
fcntl(rfd, F_SETFD, FD_CLOEXEC); |
if (wfd != -1 && wfd != rfd) |
if (wfd != -1 && wfd != rfd) |
|
|
* restore their blocking state on exit to avoid interfering |
* restore their blocking state on exit to avoid interfering |
* with other programs that follow. |
* with other programs that follow. |
*/ |
*/ |
if (rfd != -1 && !isatty(rfd) && fcntl(rfd, F_GETFL) == 0) { |
if (rfd != -1 && !isatty(rfd) && |
|
(val = fcntl(rfd, F_GETFL)) != -1 && !(val & O_NONBLOCK)) { |
c->restore_block |= CHANNEL_RESTORE_RFD; |
c->restore_block |= CHANNEL_RESTORE_RFD; |
set_nonblock(rfd); |
set_nonblock(rfd); |
} |
} |
if (wfd != -1 && !isatty(wfd) && fcntl(wfd, F_GETFL) == 0) { |
if (wfd != -1 && !isatty(wfd) && |
|
(val = fcntl(wfd, F_GETFL)) != -1 && !(val & O_NONBLOCK)) { |
c->restore_block |= CHANNEL_RESTORE_WFD; |
c->restore_block |= CHANNEL_RESTORE_WFD; |
set_nonblock(wfd); |
set_nonblock(wfd); |
} |
} |
if (efd != -1 && !isatty(efd) && fcntl(efd, F_GETFL) == 0) { |
if (efd != -1 && !isatty(efd) && |
|
(val = fcntl(efd, F_GETFL)) != -1 && !(val & O_NONBLOCK)) { |
c->restore_block |= CHANNEL_RESTORE_EFD; |
c->restore_block |= CHANNEL_RESTORE_EFD; |
set_nonblock(efd); |
set_nonblock(efd); |
} |
} |