From e5fd0bde4a58ac4048b5120a5923201600ff5134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sat, 26 Mar 2005 14:41:30 +0000 Subject: [PATCH] tcsetpgrp() and tcgetpgrp() are actually defined in unistd.h, not termios.h. Implemented them and moved them to unistd/terminal.c - not yet tested, though, but should work. As a side effect, the TTY should now send signals. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12034 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/posix/termios.h | 9 ++++--- headers/posix/unistd.h | 7 +++--- src/kernel/libroot/posix/termios.c | 28 +++++----------------- src/kernel/libroot/posix/unistd/terminal.c | 26 ++++++++++++++++---- 4 files changed, 36 insertions(+), 34 deletions(-) diff --git a/headers/posix/termios.h b/headers/posix/termios.h index 5335b29032..d3ef412039 100644 --- a/headers/posix/termios.h +++ b/headers/posix/termios.h @@ -1,6 +1,7 @@ -/* -** Distributed under the terms of the Haiku License. -*/ +/* + * Copyright 2004-2005, Haiku Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ #ifndef _TERMIOS_H_ #define _TERMIOS_H_ @@ -210,8 +211,6 @@ extern int tcsendbreak(int fd, int duration); extern int tcdrain(int fd); extern int tcflow(int fd, int action); extern int tcflush(int fd, int queueSelector); -extern int tcsetpgrp(int fd, pid_t pgrpid); -extern pid_t tcgetpgrp(int fd); #ifdef __cplusplus } diff --git a/headers/posix/unistd.h b/headers/posix/unistd.h index 10c049d309..22986b257f 100644 --- a/headers/posix/unistd.h +++ b/headers/posix/unistd.h @@ -1,6 +1,7 @@ -/* -** Distributed under the terms of the Haiku License. -*/ +/* + * Copyright 2004-2005, Haiku Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ #ifndef _UNISTD_H_ #define _UNISTD_H_ diff --git a/src/kernel/libroot/posix/termios.c b/src/kernel/libroot/posix/termios.c index 5e64886f5b..542dd78a88 100644 --- a/src/kernel/libroot/posix/termios.c +++ b/src/kernel/libroot/posix/termios.c @@ -1,8 +1,9 @@ -/* -** Copyright 2003, Daniel Reinhold, danielre@users.sf.net. All rights reserved. -** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the Haiku License. -*/ +/* + * Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Copyright 2003, Daniel Reinhold, danielre@users.sf.net. All rights reserved. + * + * Distributed under the terms of the MIT License. + */ #include @@ -134,20 +135,3 @@ cfsetospeed(struct termios *termios, speed_t speed) return 0; } - -int -tcsetpgrp(int fd, pid_t pgrpid) -{ - // ToDo: Implement! - errno = EINVAL; - return -1; -} - - -pid_t -tcgetpgrp(int fd) -{ - // ToDo: Implement! - errno = EINVAL; - return -1; -} diff --git a/src/kernel/libroot/posix/unistd/terminal.c b/src/kernel/libroot/posix/unistd/terminal.c index 53fee1fe19..d999e1bdf7 100644 --- a/src/kernel/libroot/posix/unistd/terminal.c +++ b/src/kernel/libroot/posix/unistd/terminal.c @@ -1,7 +1,7 @@ -/* -** Copyright 2003-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the Haiku License. -*/ +/* + * Copyright 2003-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ #include @@ -42,3 +42,21 @@ ctermid(char *s) return strcpy(s, name ? name : ""); } + +int +tcsetpgrp(int fd, pid_t pgrpid) +{ + return ioctl(fd, TIOCSPGRP, &pgrpid); +} + + +pid_t +tcgetpgrp(int fd) +{ + pid_t foregroundProcess; + int status = ioctl(fd, TIOCGPGRP, &foregroundProcess); + if (status == 0) + return foregroundProcess; + + return -1; +}