Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Commit

Permalink
docs: fix readme examples
Browse files Browse the repository at this point in the history
  • Loading branch information
PatchMixolydic committed Aug 14, 2021
1 parent 0b15440 commit 0f8e230
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ use pidfd::PidFd;
use pidfd_getfd::{GetFdFlags, PidFdExt};
use std::process::Command;

let child = Command::new("/usr/bin/foo").expect("failed to run `foo`");
let child = Command::new("/usr/bin/foo").spawn().expect("failed to run `foo`");
let pidfd = PidFd::from_std_checked(&child)?;
let file_from_child = pidfd.get_file(1, GetFdFlags::empty());
let file_from_child = pidfd.get_file(1, GetFdFlags::empty())?;
```

Using nightly rustc:
```rust
#![feature(linux_pidfd)]

use pidfd_getfd::{GetFdFlags, PidFdExt};
use std::{
os::linux::process::{ChildExt, CommandExt},
Expand All @@ -55,6 +57,7 @@ use std::{

let child = Command::new("/usr/bin/foo")
.create_pidfd(true)
.spawn()
.expect("failed to run `foo`");

let file_from_child = child.pidfd()?.get_file(1, GetFdFlags::empty())?;
Expand Down

0 comments on commit 0f8e230

Please sign in to comment.