From a1999d3b8a8fa78b239325a804ae2aac5f5066b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Sat, 31 Oct 2020 17:28:56 +0100 Subject: [PATCH] POSIX: add tcsetsid() Change-Id: Ia8f41e417379dcaf4f976933cf91bb2de157bc72 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3376 Reviewed-by: Adrien Destugues --- headers/posix/termios.h | 1 + src/system/libroot/posix/termios.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/headers/posix/termios.h b/headers/posix/termios.h index e8ec24428a..0be1e3cc1b 100644 --- a/headers/posix/termios.h +++ b/headers/posix/termios.h @@ -235,6 +235,7 @@ extern int tcdrain(int fd); extern int tcflow(int fd, int action); extern int tcflush(int fd, int queueSelector); extern pid_t tcgetsid(int fd); +extern int tcsetsid(int fd, pid_t pid); #ifdef __cplusplus } diff --git a/src/system/libroot/posix/termios.c b/src/system/libroot/posix/termios.c index 18b9c96c2f..5f559bedc9 100644 --- a/src/system/libroot/posix/termios.c +++ b/src/system/libroot/posix/termios.c @@ -180,3 +180,15 @@ tcgetsid(int fd) return -1; } + +int +tcsetsid(int fd, pid_t pid) +{ + if (pid != getsid(0)) { + errno = EINVAL; + return -1; + } + + return ioctl(fd, TIOCSCTTY, NULL); +} +