diff --git a/sshd.c b/sshd.c index 10c0da3b3..f264cf7e6 100644 --- a/sshd.c +++ b/sshd.c @@ -1272,6 +1272,23 @@ prepare_proctitle(int ac, char **av) return ret; } +/* Disconnect from the controlling tty. */ +void +disconnect_controlling_tty(void) +{ +#ifdef TIOCNOTTY +# ifndef O_NOCTTY +# define O_NOCTTY 0 +# endif + int fd; + + if ((fd = open(_PATH_TTY, O_RDWR | O_NOCTTY)) >= 0) { + (void) ioctl(fd, TIOCNOTTY, NULL); + close(fd); + } +#endif /* TIOCNOTTY */ +} + static void print_config(struct connection_info *connection_info) { diff --git a/sshpty.c b/sshpty.c index b3e1e2466..f8102604c 100644 --- a/sshpty.c +++ b/sshpty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sshpty.c,v 1.35 2026/02/11 17:05:32 dtucker Exp $ */ +/* $OpenBSD: sshpty.c,v 1.36 2026/09/15 06:30:58 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -39,10 +39,6 @@ # include #endif -#ifndef O_NOCTTY -#define O_NOCTTY 0 -#endif - #ifdef __APPLE__ # include # if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) @@ -212,17 +208,3 @@ 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 */ -}