about summary refs log tree commit diff
path: root/src/test/ui/command
AgeCommit message (Collapse)AuthorLines
2023-01-11Move /src/test to /testsAlbert Larsan-430/+0
2023-01-04Move testsCaio-0/+26
2022-12-27More verbose `Debug` implementation of `std::process:Command`kraktus-21/+0
based on commit: https://github.com/zackmdavis/rust/commit/ccc019aabfdd550944c049625e66c92c815ea1d0 from https://github.com/zackmdavis close https://github.com/rust-lang/rust/issues/42200 Add env variables and cwd to the shell-like debug output. Also use the alternate syntax to display a more verbose display, while not showing internal fields and hiding fields when they have their default value.
2022-10-13Adding fuchsia-ignore and needs-unwind to compiler test casesAndrew Pollack-0/+1
2022-09-24Rollup merge of #102082 - andrewpollack:uid-ignore, r=tmandryMatthias Krüger-0/+1
Adding ignore fuchsia non-applicable commands Adding ignore fuchsia non-applicable commands cc `@djkoloski` r? `@tmandry`
2022-09-24Rollup merge of #102081 - andrewpollack:add-execvp-calls-ignore, r=tmandryMatthias Krüger-0/+1
Adding ignore fuchsia tests for execvp (pre_exec) Adding ignore fuchsia tests for pre_exec, which calls execvp cc. `@djkoloski` r? `@tmandry`
2022-09-21Adding ignore fuchsia non-applicable commandsAndrew Pollack-0/+1
2022-09-21Adding ignore fuchsia tests for execvp (pre_exec)Andrew Pollack-0/+1
2022-09-20Adding ignore fuchsia tests for execvpAndrew Pollack-0/+1
2022-08-31Fix a bunch of typoDezhi Wu-1/+1
This PR will fix some typos detected by [typos]. I only picked the ones I was sure were spelling errors to fix, mostly in the comments. [typos]: https://github.com/crate-ci/typos
2021-11-05Revert "Do not call getpid wrapper after fork in tests"Josh Stone-19/+6
This reverts commit 12fbabd27f700a59d0e7031f0839b220c3514bcb. It was only needed because of using raw `clone3` instead of `fork`, but we only do that now when a pidfd is requested.
2021-08-12fix command-create-pidfd test inside unprivileged docker containersPietro Albini-1/+12
2021-08-01Check whether clone3 syscall exists in pidfd testDominik Stolz-1/+19
2021-08-01Do not call getpid wrapper after fork in testsDominik Stolz-6/+19
The test calls libc::getpid() in the pre_exec hook and asserts that the returned value is different from the PID of the parent. However, libc::getpid() returns the wrong value. Before version 2.25, glibc caches the PID of the current process with the goal of avoiding additional syscalls. The cached value is only updated when the wrapper functions for fork or clone are called. In PR #81825 we switch to directly using the clone3 syscall. Thus, the cache is not updated and getpid returns the PID of the parent. source: https://man7.org/linux/man-pages/man2/getpid.2.html#NOTES
2021-07-21Add PidFd type and seal traitsDominik Stolz-3/+3
Improve docs Split do_fork into two Make do_fork unsafe Add target attribute to create_pidfd field in Command Add method to get create_pidfd value
2021-07-21Add Linux-specific pidfd process extensionsAaron Hill-0/+27
Background: Over the last year, pidfd support was added to the Linux kernel. This allows interacting with other processes. In particular, this allows waiting on a child process with a timeout in a race-free way, bypassing all of the awful signal-handler tricks that are usually required. Pidfds can be obtained for a child process (as well as any other process) via the `pidfd_open` syscall. Unfortunately, this requires several conditions to hold in order to be race-free (i.e. the pid is not reused). Per `man pidfd_open`: ``` · the disposition of SIGCHLD has not been explicitly set to SIG_IGN (see sigaction(2)); · the SA_NOCLDWAIT flag was not specified while establishing a han‐ dler for SIGCHLD or while setting the disposition of that signal to SIG_DFL (see sigaction(2)); and · the zombie process was not reaped elsewhere in the program (e.g., either by an asynchronously executed signal handler or by wait(2) or similar in another thread). If any of these conditions does not hold, then the child process (along with a PID file descriptor that refers to it) should instead be created using clone(2) with the CLONE_PIDFD flag. ``` Sadly, these conditions are impossible to guarantee once any libraries are used. For example, C code runnng in a different thread could call `wait()`, which is impossible to detect from Rust code trying to open a pidfd. While pid reuse issues should (hopefully) be rare in practice, we can do better. By passing the `CLONE_PIDFD` flag to `clone()` or `clone3()`, we can obtain a pidfd for the child process in a guaranteed race-free manner. This PR: This PR adds Linux-specific process extension methods to allow obtaining pidfds for processes spawned via the standard `Command` API. Other than being made available to user code, the standard library does not make use of these pidfds in any way. In particular, the implementation of `Child::wait` is completely unchanged. Two Linux-specific helper methods are added: `CommandExt::create_pidfd` and `ChildExt::pidfd`. These methods are intended to serve as a building block for libraries to build higher-level abstractions - in particular, waiting on a process with a timeout. I've included a basic test, which verifies that pidfds are created iff the `create_pidfd` method is used. This test is somewhat special - it should always succeed on systems with the `clone3` system call available, and always fail on systems without `clone3` available. I'm not sure how to best ensure this programatically. This PR relies on the newer `clone3` system call to pass the `CLONE_FD`, rather than the older `clone` system call. `clone3` was added to Linux in the same release as pidfds, so this shouldn't unnecessarily limit the kernel versions that this code supports. Unresolved questions: * What should the name of the feature gate be for these newly added methods? * Should the `pidfd` method distinguish between an error occurring and `create_pidfd` not being called?
2021-05-27Test THIR unsafeck for unsafe ops in closuresLeSeulArtichaut-0/+2
2021-03-28Remove unnecessary `ignore-cloudabi` flagJohnTitor-1/+0
2021-03-09Do not attempt to unlock envlock in child process after a fork.The8472-14/+0
This is a breaking change for cases where the environment is accessed in a Command::pre_exec closure. Except for single-threaded programs these uses were not correct anyway since they aren't async-signal safe.
2021-01-29Update test-various to Ubuntu 20.04Nikita Popov-0/+1
The test command-setgroups.rs is adjusted to skip on musl, where `sysconf(_SC_NGROUPS_MAX)` always returns a dummy value of 32, even though the actual value is 65536. I'm not sure why this becomes relevant only now though, as this was apparently the case since kernel 2.6.4.
2021-01-21Update src/test/ui/command/command-setgroups.rs to ignore windowsslo1-0/+1
2021-01-21Update src/test/ui/command/command-setgroups.rsslo1-0/+6
Co-authored-by: Ashley Mannix <kodraus@hey.com>
2021-01-21Add setgroups to std::os::unix::process::CommandExtslo1-0/+19
2021-01-17Fix test to work with remote-test-server.Eric Huss-1/+7
remote-test-server does not set the current_dir, and leaves it as `/`.
2021-01-17Add test for Command::current_dir behavior.Eric Huss-0/+43
2020-11-22Drop support for cloudabi targetsLzu Tao-5/+0
2020-05-12Stabilize process_set_argv0 feature for UnixJeremy Fitzhardinge-4/+0
This stabilizes process_set_argv0 targeting 1.45.0. It has been useful in practice and seems useful as-is. The equivalent feature could be implemented for Windows, but as far as I know nobody has. That can be done separately. Tracking issue: #66510
2019-12-16Move command-related tests into command/Jeremy Fitzhardinge-0/+311