about summary refs log tree commit diff
path: root/library/std/src/sys/unix/ext
AgeCommit message (Collapse)AuthorLines
2021-05-03Move `std::sys::unix::ext` to `std::os::unix`Christiaan Dirkx-5373/+0
2021-05-02Change 'NULL' to 'null'Brent Kerby-2/+2
2021-04-30Add std::os::unix::fs::chroot to change the root directory of the current ↵Josh Triplett-0/+26
process This is a straightforward wrapper that uses the existing helpers for C string handling and errno handling. Having this available is convenient for UNIX utility programs written in Rust, and avoids having to call the unsafe `libc::chroot` directly and handle errors manually, in a program that may otherwise be entirely safe code.
2021-04-25Inline most raw socket, fd and handle conversionsKaiJewson-0/+31
2021-04-19Move `sys::vxworks` code to `sys::unix`Christiaan Dirkx-0/+2
2021-03-30Rollup merge of #83374 - reyk:fix/bsd-ancillary, r=joshtriplettDylan DPC-23/+34
unix: Fix feature(unix_socket_ancillary_data) on macos and other BSDs This adds support for CMSG handling on macOS and fixes it on OpenBSD and possibly other BSDs. When traversing the CMSG list, the previous code had an exception for Android where the next element after the last pointer could point to the first pointer instead of NULL. This is actually not specific to Android: the `libc::CMSG_NXTHDR` implementation for Linux and emscripten have a special case to return NULL when the length of the previous element is zero; most other implementations simply return the previous element plus a zero offset in this case. This MR makes the check non-optional which fixes CMSG handling and a possible endless loop on such systems; tested with file descriptor passing on OpenBSD, Linux, and macOS. This MR additionally adds `SocketAncillary::is_empty` because clippy is right that it should be added. This belongs to the `feature(unix_socket_ancillary_data)` tracking issue: https://github.com/rust-lang/rust/issues/76915 r? `@joshtriplett`
2021-03-26unix: Fix feature(unix_socket_ancillary_data) on macos and other BSDsReyk Floeter-23/+34
This adds support for CMSG handling on macOS and fixes it on OpenBSD and other BSDs. When traversing the CMSG list, the previous code had an exception for Android where the next element after the last pointer could point to the first pointer instead of NULL. This is actually not specific to Android: the `libc::CMSG_NXTHDR` implementation for Linux and emscripten have a special case to return NULL when the length of the previous element is zero; most other implementations simply return the previous element plus a zero offset in this case. This MR additionally adds `SocketAncillary::is_empty` because clippy is right that it should be added.
2021-03-26Use iter::zip in library/Josh Stone-2/+2
2021-03-26Rollup merge of #83463 - ijackson:exitstatusext-doc-grammar, r=kennytmDylan DPC-2/+2
ExitStatusExt: Fix missing word in two docs messages Looks like I missed the lack of these "and"s.
2021-03-25ExitStatusExt: Fix missing word in two docs messagesIan Jackson-2/+2
Looks like I missed the lack of these "and"s. Acked-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-03-24Rollup merge of #83353 - m-ou-se:io-error-avoid-alloc, r=nagisaDylan DPC-9/+9
Add internal io::Error::new_const to avoid allocations. This makes it possible to have a io::Error containing a message with zero allocations, and uses that everywhere to avoid the *three* allocations involved in `io::Error::new(kind, "message")`. The function signature isn't perfect, because it needs a reference to the `&str`. So for now, this is just a `pub(crate)` function. Later, we'll be able to use `fn new_const<MSG: &'static str>(kind: ErrorKind)` to make that a bit better. (Then we'll also be able to use some ZST trickery if that would result in more efficient code.) See https://github.com/rust-lang/rust/issues/83352
2021-03-22Rollup merge of #82686 - CDirkx:unix-platform, r=m-ou-seDylan DPC-4/+40
Move `std::sys::unix::platform` to `std::sys::unix::ext` This moves the operating system dependent alias `platform` (`std::os::{linux, android, ...}`) from `std::sys::unix` to `std::sys::unix::ext` (a.k.a. `std::os::unix`), removing the need for compatibility code in `unix_ext` when documenting on another platform. This is also a step in making it possible to properly move `std::sys::unix::ext` to `std::os::unix`, as ideally `std::sys` should not depend on the rest of `std`.
2021-03-21Use io::Error::new_const everywhere to avoid allocations.Mara Bos-9/+9
2021-03-10Rollup merge of #82949 - the8472:forget-envlock-on-fork, r=joshtriplettDylan DPC-1/+10
Do not attempt to unlock envlock in child process after a fork. This implements the first two points from https://github.com/rust-lang/rust/issues/64718#issuecomment-793030479 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. Note that we had a ui test that explicitly tried `env::set_var` in `pre_exec`. As expected it failed with these changes when I tested locally.
2021-03-10Rollup merge of #82411 - ijackson:fix-exitstatus, r=dtolnayYuki Okushi-2/+12
Fixes to ExitStatus and its docs * On Unix, properly display every possible wait status (and don't panic on weird values) * In the documentation, be clear and consistent about "exit status" vs "wait status".
2021-03-09Do not attempt to unlock envlock in child process after a fork.The8472-1/+10
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-03-02Move `std::sys::unix::platform` to `std::sys::unix::ext`Christiaan Dirkx-4/+40
2021-02-28unix: Non-mutable bufs in send_vectored_with_ancillary_toLinkTed-45/+48
Change the arguments of `send_vectored_with_ancillary` and `send_vectored_with_ancillary_to` to take an non-mutable bufs.
2021-02-23Update outdated comment in unix Command.Eric Huss-0/+2
2021-02-23ExitStatus: Improve documentation re wait status vs exit statusIan Jackson-2/+12
The use of `ExitStatus` as the Rust type name for a Unix *wait status*, not an *exit status*, is very confusing, but sadly probably too late to change. This area is confusing enough in Unix already (and many programmers are already confuxed). We can at least document it. I chose *not* to mention the way shells like to exit with signal numbers, thus turning signal numbers into exit statuses. This is only relevant for Rust programs using `std::process` if they run shells. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-02-10Seal the CommandExt, OsStrExt and OsStringExt traitsAmanieu d'Antras-13/+6
2021-01-21Add setgroups to std::os::unix::process::CommandExtslo1-0/+18
2021-01-13Fix typo saeled -> sealedDavid Tolnay-1/+1
2021-01-13ExitStatusExt unix: Retrospectively seal this traitIan Jackson-1/+15
As discussed in #79982. I think the "new interfaces", ie the new trait and impl, must be insta-stable. This seems OK because we are, in fact, adding a new restriction to the stable API. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-01-13unix ExitStatus: Add tracking issue to new methodsIan Jackson-4/+4
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-01-13Replace `Ie` with `In other words`Ian Jackson-1/+1
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2021-01-13Replace `Ie` with `In other words`Ian Jackson-1/+1
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2021-01-13unix ExitStatus: Provide .continued()Ian Jackson-0/+11
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-01-13unix ExitStatus: Provide .stopped_signal()Ian Jackson-0/+11
Necessary to handle WIFSTOPPED. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-01-13unix ExitStatus: Provide .core_dumpedIan Jackson-0/+8
This is essential for proper reporting of child process status on Unix. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-01-13unix ExitStatus: Provide .into_raw()Ian Jackson-0/+8
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-01-13unix ExitStatus: Clarify docs for .signal()Ian Jackson-0/+2
We need to be clear that this never returns WSTOPSIG. That is, if WIFSTOPPED, the return value is None. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2020-12-16Fix failing build of std on armv5te-unknown-linux-uclibceabi due to missing ↵Ondrej Perutka-1/+5
cmsg_len_zero
2020-12-09Auto merge of #79387 - woodruffw-forks:ww/peer-cred-pid-macos, r=Amanieubors-15/+57
ext/ucred: Support PID in peer creds on macOS This is a follow-up to https://github.com/rust-lang/rust/pull/75148 (RFC: https://github.com/rust-lang/rust/issues/42839). The original PR used `getpeereid` on macOS and the BSDs, since they don't (generally) support the `SO_PEERCRED` mechanism that Linux supplies. This PR splits the macOS/iOS implementation of `peer_cred()` from that of the BSDs, since macOS supplies the `LOCAL_PEERPID` sockopt as a source of the missing PID. It also adds a `cfg`-gated tests that ensures that platforms with support for PIDs in `UCred` have the expected data.
2020-12-02Auto merge of #69864 - LinkTed:master, r=Amanieubors-1771/+3058
unix: Extend UnixStream and UnixDatagram to send and receive file descriptors Add the functions `recv_vectored_fds` and `send_vectored_fds` to `UnixDatagram` and `UnixStream`. With this functions `UnixDatagram` and `UnixStream` can send and receive file descriptors, by using `recvmsg` and `sendmsg` system call.
2020-11-26Add comment for the previous android bug fixLinkTed-0/+4
2020-11-24Bug fix for android platform, because of the wrong behavior of CMSG_NXTHDRLinkTed-0/+19
2020-11-24ext/ucred: fmt checkWilliam Woodruff-26/+8
2020-11-24ext/ucred: Support PID in peer creds on macOSWilliam Woodruff-5/+65
2020-11-14Disambiguate symlink argument namesDavid Tolnay-3/+3
2020-11-04Fix docs for MacOs (again)LinkTed-1/+2
2020-11-03Fix docs for MacOs (correction)LinkTed-1/+2
2020-10-28Fix test cases for MacOsLinkTed-2/+28
2020-10-17Fix cannot find type `ucred` for MacOs by using fake definitionsLinkTed-1/+1
2020-10-16Take some of sys/vxworks/process/* from sys/unix instead.Mara Bos-4/+20
2020-10-16Take sys/vxworks/{fd,fs,io} from sys/unix instead.Mara Bos-0/+7
2020-10-11Fix unresolved imports for `recv_vectored_with_ancillary_from`, ↵LinkTed-0/+1
`send_vectored_with_ancillary_to` and `SocketAncillary`
2020-10-10Fix unresolved link to `SocketAncillary`LinkTed-0/+2
2020-10-10Fix `libc` is ambiguous for WindowsLinkTed-9/+6
2020-10-10Fix import errors for `#[cfg(doc)]` targetLinkTed-2/+4