Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wayslog/caoe
rust fork of https://github.com/douban/CaoE
https://github.com/wayslog/caoe
Last synced: about 20 hours ago
JSON representation
rust fork of https://github.com/douban/CaoE
- Host: GitHub
- URL: https://github.com/wayslog/caoe
- Owner: wayslog
- License: mit
- Created: 2021-08-11T11:08:47.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-09-03T09:16:38.000Z (about 3 years ago)
- Last Synced: 2024-08-02T07:02:17.262Z (3 months ago)
- Language: Rust
- Size: 20.5 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-rust-zh - CaoE - 当父进程退出杀死所有子进程
README
CaoE - Kill all children processes when the parent dies
=================CaoE makes it easy to automatically kills all spawned children (and grandchildren) processes when the parent dies, even if killed by SIGKILL, and was rewritten in Rust.
## Usage
```rust
use nix::sys::signal::Signal;// General usage, run the process in fork-and-fork model.
caoe::fork(Signal::SIGTERM).unwrap();```
## How it works
When `caoe::fork()` is called, it forks out a child process and a grandchild process. Both the parent and the child process will block, only the grandchild process will continue to run. The child process keeps checking the status of parent. If it found that the parent has died, it kills grandchild process (and grand-grandchild processes if there are any) and suicides.