You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+99-41Lines changed: 99 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,10 @@
3
3

4
4
5
5
🌳 Kill Tree is a library and CLI tool designed to terminate a specified process and all its child processes recursively, operating independently of other commands like kill or taskkill.
6
-
It is written in Rust and powered by [Tokio](https://github.com/tokio-rs/tokio).
6
+
It is written in Rust.
7
+
If you use this as a Rust library, it supports both synchronous and asynchronous implementation!
8
+
Asynchronous implementation is powerd by [Tokio](https://github.com/tokio-rs/tokio).
9
+
7
10
This project was inspired by [node-tree-kill](https://github.com/pkrumins/node-tree-kill). Thank you. 🤟
8
11
9
12
[![Build Status][actions-badge]][actions-url]
@@ -14,7 +17,17 @@ This project was inspired by [node-tree-kill](https://github.com/pkrumins/node-t
The reason I created this is because I have a case where I need to stop grandchild processes.
27
+
This is because the way to kill a grandchild process on the Windows platform is to use the `Win32` API to determine the process relationship and either kill them all (Kill Tree's implementation) or call the `taskkill` program.
28
+
Even my program is more than __3x faster__ than `taskkill`.
29
+
30
+
---
18
31
19
32
This is my first Rust crate and CLI tool. it means I started it because it was a suitable project for development with Rust.
20
33
No multi-platform library or CLI existed that could terminate processes recursively.
@@ -87,47 +100,48 @@ kill-tree 777 SIGKILL
87
100
88
101
### Using as Rust Library
89
102
90
-
⚠️ Ensure this library is executed within a Tokio runtime environment.
103
+
#### Synchronous Method
91
104
92
105
Add `kill_tree` to your dependencies.
93
106
94
107
```toml
95
108
# Cargo.toml
96
109
[dependencies]
97
-
kill_tree = "0.1"
110
+
kill_tree = "0.2"
98
111
```
99
112
113
+
Synchronous api is started with `kill_tree::blocking`.
114
+
100
115
Kill process and its children recursively with default signal `SIGTERM`.
101
116
Returns a list of process information when a function is called.
102
117
Process information is `Killed` or `MaybeAlreadyTerminated`.
103
118
If process information is `Killed` type, it has `process_id`, `parent_process_id` and `name`.
104
-
Or `MaybeAlreadyTerminated` type, it has `process_id`, `reason`.
119
+
Or `MaybeAlreadyTerminated` type, it has `process_id`, `source`.
105
120
106
121
There are two types because they can be killed during the process of querying and killing processes.
107
122
Therefore, consider the operation successful even if the query or kill process appears to fail.
108
123
This is because the purpose of this library is to make the process `not exist` state.
println!("outputs: {outputs:?}"); // The `outputs` value is the same as the example `kill_tree`.
168
223
Ok(())
169
224
}
170
225
```
171
226
227
+
When sending other signals or receiving and processing `ctrl + c` events, all you have to do is change the above `kill_tree::blocking` api to `kill_tree::tokio` and perform `await` processing, and it will be equivalent.
0 commit comments