diff options
author | 2004-09-08 14:23:49 +0000 | |
---|---|---|
committer | 2004-09-08 14:23:49 +0000 | |
commit | 05328e910d121fbb1d79686ed91aed1428afde19 (patch) | |
tree | 8b0b0155b1f641822984b7930411b002716d3c71 | |
parent | cleanup multiplex control socket on SIGHUP too, spotted by sturm@ (diff) | |
download | wireguard-openbsd-05328e910d121fbb1d79686ed91aed1428afde19.tar.xz wireguard-openbsd-05328e910d121fbb1d79686ed91aed1428afde19.zip |
after openpty() do not close() slave and reopen it. that is just crazy
talk. instead, save the descriptor and reuse it. millert ok
-rw-r--r-- | libexec/telnetd/sys_term.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libexec/telnetd/sys_term.c b/libexec/telnetd/sys_term.c index bbe0b210438..bf5030fd87d 100644 --- a/libexec/telnetd/sys_term.c +++ b/libexec/telnetd/sys_term.c @@ -352,6 +352,8 @@ getnpty() static char Xline[] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; char *line = Xline; +int slavefd = -1; + #ifdef _CRAY char myline[] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; #endif /* CRAY */ @@ -373,7 +375,7 @@ int getpty(int *ptynum) int master; int slave; if(openpty(&master, &slave, line, 0, 0) == 0){ - close(slave); + slavefd = slave; return master; } return -1; @@ -829,6 +831,10 @@ void getptyslave(void) * so that we can re-set them if we need to. */ + if (slavefd != -1) { + t = slavefd; + goto gottty; + } /* * Make sure that we don't have a controlling tty, and @@ -856,6 +862,7 @@ void getptyslave(void) # endif t = cleanopen(line); +gottty: if (t < 0) fatalperror(net, line); |