Giter Site home page Giter Site logo

winspawn's Introduction

winspawn

Spawn process for passing Universal CRT's file descriptor on windows.

Using _spawn & _dup.

Example

use winspawn::{move_fd, spawn, FileDescriptor, Mode};

use std::mem;
use std::io;
use std::fs;
use std::os::windows::io::IntoRawHandle;

fn main() -> io::Result<()> {
    let file = fs::File::open("Cargo.toml")?;
    let handle = file.into_raw_handle();
    let fd = FileDescriptor::from_raw_handle(handle, Mode::ReadOnly)?;

    let mut proc = move_fd(&fd, 3, |_| {
        // print fd 3 stat
        spawn("python", ["-c", r#""import os; print(os.stat(3))""#])
    })?;

    let exit_code = proc.wait()?;
    assert_eq!(0, exit_code);

    Ok(())
}

License: MIT/Apache-2.0

winspawn's People

Contributors

yskszk63 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.