Skip to content

Commit 618737f

Browse files
committed
Auto merge of #491 - zethra:master, r=fiveop
Added getpgrp
2 parents 2cfeb57 + 0c97f10 commit 618737f

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
2222
([#451](https://github.com/nix-rust/nix/pull/451))
2323
- Added `CLONE_NEWCGROUP` in `::nix::sched`
2424
([#457](https://github.com/nix-rust/nix/pull/457))
25+
- Added `getpgrp` in `::nix::unistd`
26+
([#491](https://github.com/nix-rust/nix/pull/491))
2527

2628
### Changed
2729
- Changed `TimeVal` into an opaque Newtype

src/unistd.rs

+11
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,17 @@ pub fn tcsetpgrp(fd: c_int, pgrp: pid_t) -> Result<()> {
151151
Errno::result(res).map(drop)
152152
}
153153

154+
155+
/// Get the group id of the calling process (see
156+
///[getpgrp(3)](http://man7.org/linux/man-pages/man3/getpgrp.3p.html)).
157+
///
158+
/// Get the process group id (PGID) of the calling process.
159+
/// According to the man page it is always successful.
160+
#[inline]
161+
pub fn getpgrp() -> pid_t {
162+
unsafe { libc::getpgrp() }
163+
}
164+
154165
/// Get the caller's thread ID (see
155166
/// [gettid(2)](http://man7.org/linux/man-pages/man2/gettid.2.html).
156167
///

0 commit comments

Comments
 (0)