summaryrefslogtreecommitdiff
path: root/sshpty.c
diff options
context:
space:
mode:
authordtucker@openbsd.org <dtucker@openbsd.org>2016-11-29 03:54:50 +0000
committerDamien Miller <djm@mindrot.org>2016-11-29 16:51:27 +1100
commitb0899ee26a6630883c0f2350098b6a35e647f512 (patch)
tree9869e87c60d4458dfc1776542c5f5c7c5ad81464 /sshpty.c
parent54d022026aae4f53fa74cc636e4a032d9689b64d (diff)
upstream commit
Factor out code to disconnect from controlling terminal into its own function. ok djm@ Upstream-ID: 39fd9e8ebd7222615a837312face5cc7ae962885
Diffstat (limited to 'sshpty.c')
-rw-r--r--sshpty.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/sshpty.c b/sshpty.c
index b8457d913..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
@@ -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}