commit 228f42aaef1ab5613f50217041a03137ba5b0364
parent 10117af2a95b8d45112f85fc0ae50a9062134afc
Author: xplshn <anto@xplshn.com.ar>
Date: Tue, 24 Nov 2026 14:54:40 -0300
getty: vhangup behind the tty backend
Diffstat:
4 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/cmd/pseudo/getty.c b/cmd/pseudo/getty.c
@@ -1,11 +1,5 @@
/* see LICENSE file for copyright and license details */
-#if FEATURE_GTTY_VHANGUP
-#ifndef _DEFAULT_SOURCE
-#define _DEFAULT_SOURCE
-#endif
-#endif
-
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -78,7 +72,7 @@ main(int argc, char *argv[])
if (ioctl(fd, TIOCSCTTY, (void *)1) != 0)
weprintf("TIOCSCTTY: could not set controlling tty\n");
#if FEATURE_GTTY_VHANGUP
- vhangup();
+ ttyhangup();
#else
eprintf("getty: vhangup support not built\n");
#endif
diff --git a/shared/libutil/tty_linux.c b/shared/libutil/tty_linux.c
@@ -1,4 +1,7 @@
/* see LICENSE file for copyright and license details */
+#ifndef _DEFAULT_SOURCE
+#define _DEFAULT_SOURCE /* vhangup */
+#endif
#include "../util.h"
/* the numbers are the ones linux gives ttys, and the dev the encoding
@@ -112,4 +115,11 @@ ttyconsterm(void)
{
return "linux";
}
+
+/* every process with the controlling tty open loses it */
+void
+ttyhangup(void)
+{
+ vhangup();
+}
#endif
diff --git a/shared/libutil/tty_other.c b/shared/libutil/tty_other.c
@@ -38,4 +38,9 @@ ttyconsterm(void)
{
return "vt100";
}
+
+void
+ttyhangup(void)
+{
+}
#endif
diff --git a/shared/util.h b/shared/util.h
@@ -116,6 +116,7 @@ void devtotty(int, int *, int *);
int ttytostr(int, int, char *, size_t);
const char *ttyconsole(void);
const char *ttyconsterm(void);
+void ttyhangup(void);
/* getopt starts over on a new argument list, the way each system's libc
* is told to: a getopt_<os>.c per system */