diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2004-09-08 14:23:50 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2004-09-08 14:23:50 +0000 |
commit | 3ffe24a1a667d36bd5ff50b6c3a6d2b819000029 (patch) | |
tree | d7919a83057ee4f936b775f29d8fa011d8f7c733 /libexec/telnetd | |
parent | 9ec0df2b975fd06441a89e1747a11f44b35318e7 (diff) |
after openpty() do not close() slave and reopen it. that is just crazy
talk. instead, save the descriptor and reuse it. millert ok
Diffstat (limited to 'libexec/telnetd')
-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); |