|
Lines 1705-1722
static int
Link Here
|
| 1705 |
ssh_session2_open(struct ssh *ssh) |
1705 |
ssh_session2_open(struct ssh *ssh) |
| 1706 |
{ |
1706 |
{ |
| 1707 |
Channel *c; |
1707 |
Channel *c; |
| 1708 |
int window, packetmax, in, out, err; |
1708 |
int window, packetmax, in, out, err, devnull; |
|
|
1709 |
|
| 1710 |
if ((devnull = open(_PATH_DEVNULL, O_RDWR)) == -1) |
| 1711 |
error("%s: open %s: %s", __func__, |
| 1712 |
_PATH_DEVNULL, strerror(errno)); |
| 1709 |
|
1713 |
|
| 1710 |
if (stdin_null_flag) { |
1714 |
if (stdin_null_flag) { |
| 1711 |
in = open(_PATH_DEVNULL, O_RDONLY); |
1715 |
in = dup(devnull); |
| 1712 |
} else { |
1716 |
} else { |
| 1713 |
in = dup(STDIN_FILENO); |
1717 |
in = dup(STDIN_FILENO); |
| 1714 |
} |
1718 |
} |
| 1715 |
out = dup(STDOUT_FILENO); |
1719 |
out = dup(STDOUT_FILENO); |
| 1716 |
err = dup(STDERR_FILENO); |
1720 |
err = dup(STDERR_FILENO); |
| 1717 |
|
1721 |
|
|
|
1722 |
/* |
| 1723 |
* stdout will henceforth be owned by the channel; clobber it here |
| 1724 |
* so channel closes are propagated to the local fd. |
| 1725 |
*/ |
| 1726 |
if (dup2(devnull, STDOUT_FILENO) < 0) |
| 1727 |
fatal("%s: dup2() stdout failed", __func__); |
| 1728 |
|
| 1718 |
if (in < 0 || out < 0 || err < 0) |
1729 |
if (in < 0 || out < 0 || err < 0) |
| 1719 |
fatal("dup() in/out/err failed"); |
1730 |
fatal("%s: dup() in/out/err failed", __func__); |
|
|
1731 |
if (devnull > STDERR_FILENO) |
| 1732 |
close(devnull); |
| 1720 |
|
1733 |
|
| 1721 |
/* enable nonblocking unless tty */ |
1734 |
/* enable nonblocking unless tty */ |
| 1722 |
if (!isatty(in)) |
1735 |
if (!isatty(in)) |