Crates.io | caoe |
lib.rs | caoe |
version | 0.1.2 |
source | src |
created_at | 2021-08-12 05:32:16.50004 |
updated_at | 2021-09-03 09:17:01.803048 |
description | CaoE makes it easy to automatically kills all spawned children (and grandchildren) processes when the parent dies, even if killed by SIGKILL. |
homepage | |
repository | |
max_upload_size | |
id | 435069 |
size | 11,075 |
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.
use nix::sys::signal::Signal;
// General usage, run the process in fork-and-fork model.
caoe::fork(Signal::SIGTERM).unwrap();
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.