Skip to content

Commit

Permalink
Auto merge of #451 - zethra:master, r=kamalmarhubi
Browse files Browse the repository at this point in the history
Added tcgetpgrp and tcsetpgrp

I added the tcgetpgrp and tcsetpgrp functions.  I'm not sure if I did everything right so please tell me if I need to change anything.
  • Loading branch information
homu committed Nov 8, 2016
2 parents f8d4c31 + 013e7c8 commit 1dc37a0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
([#448](https://github.com/nix-rust/nix/pull/448))
- Added `getpgid` in `::nix::unistd`
([#433](https://github.com/nix-rust/nix/pull/433))
- Added `tcgetpgrp` and `tcsetpgrp` in `::nix::unistd`
([#451](https://github.com/nix-rust/nix/pull/451))

### Changed
- The minimum supported version of rustc is now 1.7.0.
Expand Down
22 changes: 22 additions & 0 deletions src/unistd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,28 @@ pub fn setsid() -> Result<pid_t> {
Errno::result(unsafe { libc::setsid() })
}


/// Get the terminal foreground process group (see
/// [tcgetpgrp(3)](http://man7.org/linux/man-pages/man3/tcgetpgrp.3.html)).
///
/// Get the group process id (GPID) of the foreground process group on the
/// terminal associated to file descriptor (FD).
#[inline]
pub fn tcgetgrp(fd: c_int) -> Result<pid_t> {
let res = unsafe { libc::tcgetpgrp(fd) };
Errno::result(res)
}
/// Set the terminal foreground process group (see
/// [tcgetpgrp(3)](http://man7.org/linux/man-pages/man3/tcgetpgrp.3.html)).
///
/// Get the group process id (PGID) to the foreground process group on the
/// terminal associated to file descriptor (FD).
#[inline]
pub fn tcsetpgrp(fd: c_int, pgrp: pid_t) -> Result<()> {
let res = unsafe { libc::tcsetpgrp(fd, pgrp) };
Errno::result(res).map(drop)
}

/// Get the caller's thread ID (see
/// [gettid(2)](http://man7.org/linux/man-pages/man2/gettid.2.html).
///
Expand Down

0 comments on commit 1dc37a0

Please sign in to comment.