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:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user