Skip to content

Commit f07aee0

Browse files
committed
add 11_1_2
1 parent fe8224b commit f07aee0

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

Cargo.lock

Lines changed: 26 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chapter11/Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,9 @@ edition = "2018"
77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88

99
[dependencies]
10-
lib = { path = "../lib" }
10+
lib = { path = "../lib" }
11+
nix = "0.21.0"
12+
13+
[[bin]]
14+
name = "11_1_2"
15+
path = "src/11_1_2/main.rs"

chapter11/src/11_1_2/main.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
use nix::unistd::{getpid, getppid};
2+
3+
fn main() {
4+
// nix を使用してもよい。
5+
println!("プロセス ID: {}", getpid());
6+
// あるいは、Rust の std::process::id を使用しても取得できる。
7+
// println!("プロセス ID: {}", std::process::id());
8+
println!("親プロセスID: {}", getppid());
9+
}

0 commit comments

Comments
 (0)