summaryrefslogtreecommitdiff
path: root/src/sys/termios.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/sys/termios.rs')
-rw-r--r--src/sys/termios.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/sys/termios.rs b/src/sys/termios.rs
index 2a815158..8651a84d 100644
--- a/src/sys/termios.rs
+++ b/src/sys/termios.rs
@@ -50,6 +50,8 @@ use std::convert::From;
use std::mem;
use std::os::unix::io::RawFd;
+use ::unistd::Pid;
+
/// Stores settings for the termios API
///
/// 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<()> {
pub fn tcsendbreak(fd: RawFd, duration: c_int) -> Result<()> {
Errno::result(unsafe { libc::tcsendbreak(fd, duration) }).map(drop)
}
+
+/// Get the session controlled by the given terminal (see
+/// [tcgetsid(3)](http://pubs.opengroup.org/onlinepubs/9699919799/functions/tcgetsid.html)).
+pub fn tcgetsid(fd: RawFd) -> Result<Pid> {
+ let res = unsafe { libc::tcgetsid(fd) };
+
+ Errno::result(res).map(Pid::from_raw)
+}