Skip to content

Feature request: add method to unix::process::CommandExt to set argv[0] #66510

Closed
@jsgf

Description

@jsgf

In Unix, the first process argument is the executable name by convention. However, there are various occasions where you might want to set argv[0] to something other than the full executable path:

  • to set a normalized program name
  • to put multiple functions into one executable, selected by argv[0]
  • to put commentary on the execution context for a process
  • etc

I suggest adding a set_argv_0<S: AsRef<OsStr>(&mut self, arg: S) -> process::Command to std::os::unix::process::CommandExt to allow argv[0] to be overridden.

The default behaviour would remain unchanged.

It would require a little more implementation change - currently it always executes self.get_argv()[0], but this should be changed to self.program.as_ptr().

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-unstableBlocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions