Skip to content

Commit b05c1e4

Browse files
committed
Auto merge of #433 - kiddkai:getpgid, r=posborne
add getpgid call Add a `getpgid` function to nix. Argument is required, either pass in `None` or `Some(pid_t)`. It should have the same behavior as the `libc` one.
2 parents 8d0e312 + ac51932 commit b05c1e4

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1414
([#410](https://github.com/nix-rust/nix/pull/410))
1515
- Added `setresuid` and `setresgid` for Linux in `::nix::unistd`
1616
([#448](https://github.com/nix-rust/nix/pull/448))
17+
- Added `getpgid` in `::nix::unistd`
18+
([#433](https://github.com/nix-rust/nix/pull/433))
1719

1820
### Changed
1921
- The minimum supported version of rustc is now 1.7.0.

src/unistd.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ pub fn setpgid(pid: pid_t, pgid: pid_t) -> Result<()> {
6262
let res = unsafe { libc::setpgid(pid, pgid) };
6363
Errno::result(res).map(drop)
6464
}
65+
#[inline]
66+
pub fn getpgid(pid: Option<pid_t>) -> Result<pid_t> {
67+
let res = unsafe { libc::getpgid(pid.unwrap_or(0 as pid_t)) };
68+
Errno::result(res)
69+
}
6570

6671
#[cfg(any(target_os = "linux", target_os = "android"))]
6772
#[inline]

0 commit comments

Comments
 (0)