about summary refs log tree commit diff
path: root/src/libstd/sys/unix/process
AgeCommit message (Collapse)AuthorLines
2020-07-27mv std libs to library/mark-1543/+0
2020-07-19Rollup merge of #74356 - lzutao:rm_combine, r=LukasKalbertodtManish Goregaokar-7/+3
Remove combine function Comparing two array directly helps generate better assert message. Resolve https://github.com/rust-lang/rust/pull/74271/files#r454538514
2020-07-15Rollup merge of #74291 - regexident:from-docs, r=GuillaumeGomezManish Goregaokar-0/+2
Added docs for `From<c_int>` for `ExitStatus` Partially addresses https://github.com/rust-lang/rust/issues/51430
2020-07-15Remove combine functionLzu Tao-7/+3
Comparing two array directly helps generate better assert message
2020-07-14Added docs for `From<c_int>` for `ExitStatus`Vincent Esche-0/+2
2020-07-12process_unix: prefer i32::*_be_bytes over manually shifting bytesLzu Tao-14/+12
2020-06-09Mark tests whcih don't work under riscv emulationTom Eccles-0/+1
2020-05-22Implement `Sync` for `process::Command on unix and vxworksLeSeulArtichaut-2/+4
2020-03-31more clippy fixesMatthias Krüger-1/+1
use is_empty() instead of len comparison (clippy::len_zero) use if let instead of while let loop that never loops (clippy::never_loop) remove redundant returns (clippy::needless_return) remove redundant closures (clippy::redundant_closure) use if let instead of match and wildcard pattern (clippy::single_match) don't repeat field names redundantly (clippy::redundant_field_names)
2020-03-05Const items have by default a static lifetime, there's no need to annotate ↵Matthias Krüger-2/+2
it. (clippy::redundant_static_lifetimes)
2020-02-27don't use .into() to convert types into identical types.Matthias Krüger-3/+1
example: let s: String = format!("hello").into();
2020-01-02Use drop instead of the toilet closure `|_| ()`Lzu Tao-1/+1
2019-12-22Format the worldMark Rousskov-84/+88
2019-12-16Fix up Command Debug output when arg0 is specified.Jeremy Fitzhardinge-2/+6
PR https://github.com/rust-lang/rust/pull/66512 added the ability to set argv[0] on Command. As a side effect, it changed the Debug output to print both the program and argv[0], which in practice results in stuttery output ("echo echo foo"). This PR reverts the behaviour to the the old one, so that the command is only printed once - unless arg0 has been set. In that case it emits "[command] arg0 arg1 ...".
2019-11-29Format libstd/sys with rustfmtDavid Tolnay-139/+200
This commit applies rustfmt with rust-lang/rust's default settings to files in src/libstd/sys *that are not involved in any currently open PR* to minimize merge conflicts. THe list of files involved in open PRs was determined by querying GitHub's GraphQL API with this script: https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8 With the list of files from the script in outstanding_files, the relevant commands were: $ find src/libstd/sys -name '*.rs' \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ rg libstd/sys outstanding_files | xargs git checkout -- Repeating this process several months apart should get us coverage of most of the rest of the files. To confirm no funny business: $ git checkout $THIS_COMMIT^ $ git show --pretty= --name-only $THIS_COMMIT \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ git diff $THIS_COMMIT # there should be no difference
2019-11-19Add unix::process::CommandExt::arg0Jeremy Fitzhardinge-10/+19
This allows argv[0] to be overridden on the executable's command-line. This also makes the program executed independent of argv[0]. Does Fuchsia have the same semantics? Addresses: #66510
2019-09-25Fix ExitStatus on FuchsiaTyler Mandry-75/+93
Fuchsia exit codes don't follow the convention of libc::WEXITSTATUS et al, and they are 64 bits instead of 32 bits. This gives Fuchsia its own representation of ExitStatus. Additionally, the zircon syscall structs were out of date, causing us to see bogus return codes.
2019-09-07Rollup merge of #64023 - tmandry:libstd-fuchsia-fixes, r=cramertjMazdak Farrokhzad-27/+76
libstd fuchsia fixes This fixes two bugs in libstd on Fuchsia: - `zx_time_t` was changed to an `i64`, but this never made it into libstd - When spawning processes where any of the stdio were null, libstd attempts to open `/dev/null`, which doesn't exist on Fuchsia r? @cramertj
2019-09-05std: Improve downstream codegen in `Command::env`Alex Crichton-4/+5
This commit rejiggers the generics used in the implementation of `Command::env` with the purpose of reducing the amount of codegen that needs to happen in consumer crates, instead preferring to generate code into libstd. This was found when profiling the compile times of the `cc` crate where the binary rlib produced had a lot of `BTreeMap` code compiled into it but the crate doesn't actually use `BTreeMap`. It turns out that `Command::env` is generic enough to codegen the entire implementation in calling crates, but in this case there's no performance concern so it's fine to compile the code into the standard library. This change is done by removing the generic on the `CommandEnv` map which is intended to handle case-insensitive variables on Windows. Instead now a generic isn't used but rather a `use` statement defined per-platform is used. With this commit a debug build of `Command::new("foo").env("a", "b")` drops from 21k lines of LLVM IR to 10k.
2019-08-30fuchsia: Fix default environment behavior when spawningTyler Mandry-2/+5
2019-08-30fuchsia: Don't fail to spawn if no stdin existsTyler Mandry-22/+41
2019-08-30Don't try to use /dev/null on FuchsiaTyler Mandry-9/+36
2019-08-29Update zx_time_t to an i64Tyler Mandry-3/+3
2019-08-23Auto merge of #63521 - newpavlov:redox_builder, r=pietroalbinibors-13/+12
Re-enable Redox builder (take 2) Closes: #63160
2019-08-19Consolidate sigemptyset workaroundsJoe Richey-40/+27
In sys/unix/process, we work around the sigemptyset linking issues on android in two different ways. This change consolidates these workarounds, and avoids duplicating bindings from `libc`.
2019-08-19remove any from cfgsArtyom Pavlov-2/+2
2019-08-19cfg fix 2Artyom Pavlov-1/+2
2019-08-19fix cfgArtyom Pavlov-11/+9
2019-08-06Fix cfg_if usageJeremy Soller-1/+1
2019-08-06redox: convert to target_family unixJeremy Soller-9/+20
2019-07-18Fix clippy::len_zero warningsMateusz Mikuła-1/+1
2019-06-26Use pointer::write_bytes for android sigemptysetJosh Stone-5/+3
2019-06-26Avoid mem::uninitialized() in std::sys::unixJosh Stone-34/+34
For `libc` types that will be initialized in FFI calls, we can just use `MaybeUninit` and then pass around raw pointers. For `sun_path_offset()`, which really wants `offset_of`, all callers have a real `sockaddr_un` available, so we can use that reference.
2019-05-06use exhaustive_patterns to be able to use `?`Marcel Hellwig-5/+6
2019-05-06convert custom try macro to `?`Marcel Hellwig-17/+10
resolves #60580
2019-03-31libstd: deny(elided_lifetimes_in_paths)Mazdak Farrokhzad-2/+2
2019-02-28libstd => 2018Taiki Endo-45/+47
2019-02-22Rollup merge of #58059 - RalfJung:before_exec, r=alexcrichtonMazdak Farrokhzad-2/+4
deprecate before_exec in favor of unsafe pre_exec Fixes https://github.com/rust-lang/rust/issues/39575 As per the [lang team decision](https://github.com/rust-lang/rust/issues/39575#issuecomment-442993358): > The language team agreed that before_exec should be unsafe, and leaves the details of a transition plan to the libs team. Cc @alexcrichton @rust-lang/libs how would you like to proceed?
2019-02-13Use posix_spawn_file_actions_addchdir_np when possibleJosh Stone-2/+22
This is a non-POSIX extension implemented in Solaris and in glibc 2.29. With this we can still use `posix_spawn()` when `Command::current_dir()` has been set, otherwise we fallback to `fork(); chdir(); exec()`.
2019-02-10libs: doc commentsAlexander Regueiro-1/+1
2019-02-03more formattingRalf Jung-2/+4
2019-02-01deprecate before_exec in favor of unsafe pre_execRalf Jung-1/+1
2018-12-25Remove licensesMark Rousskov-50/+0
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-1/+1
2018-12-04cleanup: remove static lifetimes from consts in libstdljedrz-1/+1
2018-11-14std: Synchronize access to global env during `exec`Alex Crichton-8/+48
This commit, after reverting #55359, applies a different fix for #46775 while also fixing #55775. The basic idea was to go back to pre-#55359 libstd, and then fix #46775 in a way that doesn't expose #55775. The issue described in #46775 boils down to two problems: * First, the global environment is reset during `exec` but, but if the `exec` call fails then the global environment was a dangling pointer into free'd memory as the block of memory was deallocated when `Command` is dropped. This is fixed in this commit by installing a `Drop` stack object which ensures that the `environ` pointer is preserved on a failing `exec`. * Second, the global environment was accessed in an unsynchronized fashion during `exec`. This was fixed by ensuring that the Rust-specific environment lock is acquired for these system-level operations. Thanks to Alex Gaynor for pioneering the solution here! Closes #55775 Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
2018-11-14Revert "Fixes #46775 -- don't mutate the process's environment in Command::exec"Alex Crichton-99/+8
This reverts commit 36fe3b605a7a7143a14565272140ba1b43c1b041.
2018-11-01Fixes #46775 -- don't mutate the process's environment in Command::execAlex Gaynor-8/+99
Instead, pass the environment to execvpe, so the kernel can apply it directly to the new process. This avoids a use-after-free in the case where exec'ing the new process fails for any reason, as well as a race condition if there are other threads alive during the exec.
2018-10-19Prefer unwrap_or_else to unwrap_or in case of function calls/allocationsljedrz-1/+1
2018-07-10Add missing `dyn` for cloudabi, redox, unix and wasmljedrz-3/+3