Skip to content

Commit 70f332d

Browse files
committed
Add tcgetsid()
1 parent 3efbc96 commit 70f332d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/sys/termios.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ use std::convert::From;
5050
use std::mem;
5151
use std::os::unix::io::RawFd;
5252

53+
use ::unistd::Pid;
54+
5355
/// Stores settings for the termios API
5456
///
5557
/// This is a wrapper around the `libc::termios` struct that provides a safe interface for the
@@ -883,3 +885,11 @@ pub fn tcflush(fd: RawFd, action: FlushArg) -> Result<()> {
883885
pub fn tcsendbreak(fd: RawFd, duration: c_int) -> Result<()> {
884886
Errno::result(unsafe { libc::tcsendbreak(fd, duration) }).map(drop)
885887
}
888+
889+
/// Get the session controlled by the given terminal (see
890+
/// [tcgetsid(3)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/tcgetsid.html)).
891+
pub fn tcgetsid(fd: RawFd) -> Result<Pid> {
892+
let res = unsafe { libc::tcgetsid(fd) };
893+
894+
Errno::result(res).map(Pid::from_raw)
895+
}

0 commit comments

Comments
 (0)