From b0899ee26a6630883c0f2350098b6a35e647f512 Mon Sep 17 00:00:00 2001 From: "dtucker@openbsd.org" Date: Tue, 29 Nov 2016 03:54:50 +0000 Subject: upstream commit Factor out code to disconnect from controlling terminal into its own function. ok djm@ Upstream-ID: 39fd9e8ebd7222615a837312face5cc7ae962885 --- sshpty.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'sshpty.c') diff --git a/sshpty.c b/sshpty.c index b8457d913..fe2fb5aa2 100644 --- a/sshpty.c +++ b/sshpty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshpty.c,v 1.30 2015/07/30 23:09:15 djm Exp $ */ +/* $OpenBSD: sshpty.c,v 1.31 2016/11/29 03:54:50 dtucker Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -238,3 +238,17 @@ pty_setowner(struct passwd *pw, const char *tty) } } } + +/* Disconnect from the controlling tty. */ +void +disconnect_controlling_tty(void) +{ +#ifdef TIOCNOTTY + int fd; + + if ((fd = open(_PATH_TTY, O_RDWR | O_NOCTTY)) >= 0) { + (void) ioctl(fd, TIOCNOTTY, NULL); + close(fd); + } +#endif /* TIOCNOTTY */ +} -- cgit v1.2.3