Skip to content

Commit

Permalink
update example
Browse files Browse the repository at this point in the history
  • Loading branch information
nbari committed Feb 1, 2024
1 parent d7e9254 commit 5b1fe5d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@ Example:

Create a new test project:

$ cargo new --bin fork
$ cargo new --bin myapp

> To install `cargo` use: `curl https://sh.rustup.rs -sSf | sh`
Edit `fork/Cargo.toml` and add to `[dependencies]`:
Add `fork` as a depdendecie:

cargo add fork

or Edit `myapp/Cargo.toml` and add to `[dependencies]`:

fork = "0.1"

Add the following code to `fork/main.rs`
Add the following code to `myapp/main.rs`

```rs
use fork::{daemon, Fork};
Expand All @@ -50,15 +54,15 @@ Test running:

Use `ps` to check the process, for example:

$ ps -axo ppid,pid,pgid,sess,tty,tpgid,stat,uid,%mem,%cpu,command, | egrep "fork|sleep|PID"
$ ps -axo ppid,pid,pgid,sess,tty,tpgid,stat,uid,%mem,%cpu,command, | egrep "myapp|sleep|PID"

> `egrep` is used to show the `ps` headers
Output should be something like:

```pre
PPID PID PGID SESS TTY TPGID STAT UID %MEM %CPU COMMAND
1 48738 48737 0 ?? 0 S 501 0.0 0.0 target/debug/fork
1 48738 48737 0 ?? 0 S 501 0.0 0.0 target/debug/myapp
48738 48753 48737 0 ?? 0 S 501 0.0 0.0 sleep 300
```

Expand All @@ -67,5 +71,5 @@ Output should be something like:
* new `PGID = 48737`

1 - root (init/launchd)
\-- 48738 fork PGID - 48737
\-- 48738 myapp PGID - 48737
\--- 48753 sleep PGID - 48737

0 comments on commit 5b1fe5d

Please sign in to comment.