summaryrefslogtreecommitdiff
path: root/pty.c
diff options
context:
space:
mode:
Diffstat (limited to 'pty.c')
-rw-r--r--pty.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/pty.c b/pty.c
index c6af6f471..21ddab5c2 100644
--- a/pty.c
+++ b/pty.c
@@ -14,7 +14,7 @@
14 */ 14 */
15 15
16#include "includes.h" 16#include "includes.h"
17RCSID("$Id: pty.c,v 1.18 2000/04/16 01:18:44 damien Exp $"); 17RCSID("$Id: pty.c,v 1.19 2000/04/20 13:12:59 damien Exp $");
18 18
19#ifdef HAVE_UTIL_H 19#ifdef HAVE_UTIL_H
20# include <util.h> 20# include <util.h>
@@ -201,6 +201,9 @@ void
201pty_make_controlling_tty(int *ttyfd, const char *ttyname) 201pty_make_controlling_tty(int *ttyfd, const char *ttyname)
202{ 202{
203 int fd; 203 int fd;
204#ifdef HAVE_VHANGUP
205 void *old;
206#endif /* HAVE_VHANGUP */
204 207
205 /* First disconnect from the old controlling tty. */ 208 /* First disconnect from the old controlling tty. */
206#ifdef TIOCNOTTY 209#ifdef TIOCNOTTY
@@ -232,12 +235,22 @@ pty_make_controlling_tty(int *ttyfd, const char *ttyname)
232 */ 235 */
233 ioctl(*ttyfd, TIOCSCTTY, NULL); 236 ioctl(*ttyfd, TIOCSCTTY, NULL);
234#endif /* TIOCSCTTY */ 237#endif /* TIOCSCTTY */
238#ifdef HAVE_VHANGUP
239 old = signal(SIGHUP, SIG_IGN);
240 vhangup();
241 signal(SIGHUP, old);
242#endif /* HAVE_VHANGUP */
235 fd = open(ttyname, O_RDWR); 243 fd = open(ttyname, O_RDWR);
236 if (fd < 0) 244 if (fd < 0) {
237 error("%.100s: %.100s", ttyname, strerror(errno)); 245 error("%.100s: %.100s", ttyname, strerror(errno));
238 else 246 } else {
247#ifdef HAVE_VHANGUP
248 close(*ttyfd);
249 *ttyfd = fd;
250#else /* HAVE_VHANGUP */
239 close(fd); 251 close(fd);
240 252#endif /* HAVE_VHANGUP */
253 }
241 /* Verify that we now have a controlling tty. */ 254 /* Verify that we now have a controlling tty. */
242 fd = open("/dev/tty", O_WRONLY); 255 fd = open("/dev/tty", O_WRONLY);
243 if (fd < 0) 256 if (fd < 0)