Skip to content

Commit cd45c9f

Browse files
committed
add 11_1_3 & 11_1_4
1 parent bf336a5 commit cd45c9f

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

chapter11/src/11_1_3/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
use nix::unistd::{getpgrp, getpid, getsid};
2+
13
fn main() {
2-
println!("11_1_3");
4+
let sid = getsid(Some(getpid())).unwrap();
5+
println!("グループID: {}, セッションID: {}", getpgrp(), sid);
36
}

chapter11/src/11_1_4/main.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
use nix::unistd::getgroups;
2+
use nix::unistd::{getgid, getuid};
3+
14
fn main() {
2-
println!("11_1_4");
5+
println!("ユーザーID: {}", getuid());
6+
println!("グループID: {}", getgid());
7+
8+
// nix クレートにおける getgroups は Apple のプラットフォームでは実行できない。
9+
let groups = getgroups().unwrap();
10+
println!("サブグループID: {:?}", groups);
311
}

0 commit comments

Comments
 (0)