GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - PatchMixolydic/pidfd_getfd: Moved to Codeberg — check the URL in the repo!

This repository was archived by the owner on Jul 10, 2023. It is now read-only.
BranchesTags
Open more actions menu

Latest commit

 

History

20 Commits
20 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
src
src
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
Cargo.toml
Cargo.toml
 
 
LICENSE-APACHE
LICENSE-APACHE
 
 
LICENSE-MIT
LICENSE-MIT
 
 
README.md
README.md
 
 

Repository files navigation

pidfd_getfd

pidfd_getfd on crates.io Latest documentation on docs.rs License information for pidfd-getfd

This crate provides a direct binding to the pidfd_getfd syscall along with a slightly more convenient wrapper, get_file_from_pidfd. This also contains an extension trait for pidfd::PidFd and std's PidFd (currently only available on nightly rustc) which provides access to get_file_from_pidfd via PidFdExt::get_file().

Note that pidfds are currently only supported on Linux 5.6 or later, thus this crate will only work on Linux. If any other platform gains support for pidfds, please let me know through an issue or pull request!

Please note that this crate has not been thoroughly tested. Viewer discretion is advised.

Example

use pidfd_getfd::{get_file_from_pidfd, GetFdFlags};
use std::{
    io::{self, Read},
    os::unix::prelude::RawFd,
};

let pidfd: RawFd = /* ... */;
let target_fd: RawFd = /* ... */;
let mut file = get_file_from_pidfd(pidfd, target_fd, GetFdFlags::empty())?;
let mut buf = Vec::new();
file.read_to_end(&mut buf)?;
println!("{:#?}", buf);
Ok(())

Using pidfd:

use pidfd::PidFd;
use pidfd_getfd::{GetFdFlags, PidFdExt};
use std::process::Command;

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())?;

Using nightly rustc:

#![feature(linux_pidfd)]

use pidfd_getfd::{GetFdFlags, PidFdExt};
use std::{
    os::linux::process::{ChildExt, CommandExt},
    process::Command,
};

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())?;

About

Moved to Codeberg — check the URL in the repo!

codeberg.org/PatchMixolydic/pidfd_getfd

Resources

Readme
Activity

Stars

2 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.