Skip to content

Support unix exec for replacing current process #61

Description

@neilyio

It would be handy to be able to use Command::exec() with a convenient macro. I commonly use this when I need to transform the current process entirely into another process without creating a new subprocess. This can be particularly useful for creating wrappers around other programs or for use in certain types of daemon processes.

For example:

use std::os::unix::process::CommandExt;
use std::process::Command;

fn main() {
    let error = Command::new("ls")
        .arg("-l")
        .arg("/home")
        .exec();  // Replaces the current process with `ls`

    eprintln!("Failed to execute ls: {}", error);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions