summaryrefslogtreecommitdiff
path: root/sshpty.c
diff options
context:
space:
mode:
Diffstat (limited to 'sshpty.c')
-rw-r--r--sshpty.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/sshpty.c b/sshpty.c
index 15da8c649..fe2fb5aa2 100644
--- a/sshpty.c
+++ b/sshpty.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshpty.c,v 1.30 2015/07/30 23:09:15 djm Exp $ */ 1/* $OpenBSD: sshpty.c,v 1.31 2016/11/29 03:54:50 dtucker Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -155,11 +155,11 @@ pty_make_controlling_tty(int *ttyfd, const char *tty)
155 error("SETPGRP %s",strerror(errno)); 155 error("SETPGRP %s",strerror(errno));
156#endif /* NEED_SETPGRP */ 156#endif /* NEED_SETPGRP */
157 fd = open(tty, O_RDWR); 157 fd = open(tty, O_RDWR);
158 if (fd < 0) { 158 if (fd < 0)
159 error("%.100s: %.100s", tty, strerror(errno)); 159 error("%.100s: %.100s", tty, strerror(errno));
160 } else { 160 else
161 close(fd); 161 close(fd);
162 } 162
163 /* Verify that we now have a controlling tty. */ 163 /* Verify that we now have a controlling tty. */
164 fd = open(_PATH_TTY, O_WRONLY); 164 fd = open(_PATH_TTY, O_WRONLY);
165 if (fd < 0) 165 if (fd < 0)
@@ -238,3 +238,17 @@ pty_setowner(struct passwd *pw, const char *tty)
238 } 238 }
239 } 239 }
240} 240}
241
242/* Disconnect from the controlling tty. */
243void
244disconnect_controlling_tty(void)
245{
246#ifdef TIOCNOTTY
247 int fd;
248
249 if ((fd = open(_PATH_TTY, O_RDWR | O_NOCTTY)) >= 0) {
250 (void) ioctl(fd, TIOCNOTTY, NULL);
251 close(fd);
252 }
253#endif /* TIOCNOTTY */
254}