|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+use std::process::Command;
|
|
|
2
|
+use std::{thread, time};
|
|
|
3
|
+use nix::sys::signal::*;
|
|
|
4
|
+use nix::unistd::{fork, ForkResult};
|
|
|
5
|
+
|
|
|
6
|
+pub fn run_zombie() {
|
|
|
7
|
+ match fork().expect("Fork failed") {
|
|
|
8
|
+
|
|
|
9
|
+ // In case this is the Parent process, kill the new child.
|
|
|
10
|
+ ForkResult::Parent{ child } => {
|
|
|
11
|
+ kill(child, SIGKILL).expect("Kill failed");
|
|
|
12
|
+ },
|
|
|
13
|
+
|
|
|
14
|
+ // In case this is the Child process, wait until killed.
|
|
|
15
|
+ ForkResult::Child => {
|
|
|
16
|
+ thread::sleep(
|
|
|
17
|
+ time::Duration::new(5000, 0) //Wait for a long time
|
|
|
18
|
+ );
|
|
|
19
|
+ }
|
|
|
20
|
+ }
|
|
|
21
|
+
|
|
|
22
|
+
|
|
|
23
|
+ let output = Command::new("ps").arg("t").output().expect("Error in run_zombie");
|
|
|
24
|
+
|
|
|
25
|
+ println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
|
|
|
26
|
+}
|