POSIX: add tcgetsid()

Change-Id: If58141b4e56b7fe444460b6808e33abc5ea71f37
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3374
Reviewed-by: Axel Dörfler <[email protected]>
This commit is contained in:
Jérôme Duval
2020-11-04 06:18:17 +00:00
parent 102bf4b799
commit b48159dce2
3 changed files with 24 additions and 0 deletions
+2
View File
@@ -187,6 +187,7 @@ struct termios {
#define TIOCCBRK (TCGETA + 21) /* both are a frontend to TCSBRK */
#define TIOCMBIS (TCGETA + 22) /* set bits in line state */
#define TIOCMBIC (TCGETA + 23) /* clear bits in line state */
#define TIOCGSID (TCGETA + 24) /* get session leader process group ID */
/* Event codes. Returned from TCWAITEVENT */
#define EV_RING 0x0001
@@ -233,6 +234,7 @@ 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 pid_t tcgetsid(int fd);
#ifdef __cplusplus
}
+9
View File
@@ -1679,6 +1679,15 @@ tty_ioctl(tty_cookie* cookie, uint32 op, void* buffer, size_t length)
return B_OK;
}
// get session leader process group ID
case TIOCGSID:
{
TRACE(("tty: get session_id\n"));
return user_memcpy(buffer, &tty->settings->session_id,
sizeof(pid_t));
}
// get and set window size
case TIOCGWINSZ:
+13
View File
@@ -167,3 +167,16 @@ cfmakeraw(struct termios *termios)
termios->c_cflag &= ~(CSIZE | PARENB);
termios->c_cflag |= CS8;
}
pid_t
tcgetsid(int fd)
{
int sid;
if (ioctl(fd, TIOCGSID, &sid) == 0)
return sid;
return -1;
}