diff options
| author | bors <bors@rust-lang.org> | 2024-04-16 13:26:03 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-04-16 13:26:03 +0000 |
| commit | 1dea922ea6e74f99a0e97de5cdb8174e4dea0444 (patch) | |
| tree | b74718d27845c12af9cff42865edb0d768e5a2b9 /library/std/src | |
| parent | 4e1f5d90bca45207605a88e39b1f76abcdb85d2f (diff) | |
| parent | f11b21bdb77c8308c0fc81340b44b1881b665f97 (diff) | |
| download | rust-1dea922ea6e74f99a0e97de5cdb8174e4dea0444.tar.gz rust-1dea922ea6e74f99a0e97de5cdb8174e4dea0444.zip | |
Auto merge of #124015 - GuillaumeGomez:rollup-s46ksxa, r=GuillaumeGomez
Rollup of 14 pull requests Successful merges: - #120781 (Correct usage note on OpenOptions::append()) - #121694 (sess: stabilize `-Zrelro-level` as `-Crelro-level`) - #122521 (doc(bootstrap): add top-level doc-comment to utils/tarball.rs) - #123491 (Fix ICE in `eval_body_using_ecx`) - #123574 (rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 6)) - #123687 (Update ar_archive_writer to 0.2.0) - #123721 (Various visionOS fixes) - #123797 (Better graphviz output for SCCs and NLL constraints) - #123990 (Make `suggest_deref_closure_return` more idiomatic/easier to understand) - #123995 (Make `thir_tree` and `thir_flat` into hooks) - #123998 (Opaque types have no namespace) - #124001 (Fix docs for unstable_features lint.) - #124006 (Move size assertions for `mir::syntax` types into the same file) - #124011 (rustdoc: update the module-level docs of `rustdoc::clean`) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/fs.rs | 27 | ||||
| -rw-r--r-- | library/std/src/sys/pal/unix/process/process_unix.rs | 13 |
2 files changed, 19 insertions, 21 deletions
diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 8a24949631c..1293abddaf3 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -980,15 +980,21 @@ impl OpenOptions { /// Note that setting `.write(true).append(true)` has the same effect as /// setting only `.append(true)`. /// - /// For most filesystems, the operating system guarantees that all writes are - /// atomic: no writes get mangled because another process writes at the same - /// time. - /// - /// One maybe obvious note when using append-mode: make sure that all data - /// that belongs together is written to the file in one operation. This - /// can be done by concatenating strings before passing them to [`write()`], - /// or using a buffered writer (with a buffer of adequate size), - /// and calling [`flush()`] when the message is complete. + /// Append mode guarantees that writes will be positioned at the current end of file, + /// even when there are other processes or threads appending to the same file. This is + /// unlike <code>[seek]\([SeekFrom]::[End]\(0))</code> followed by `write()`, which + /// has a race between seeking and writing during which another writer can write, with + /// our `write()` overwriting their data. + /// + /// Keep in mind that this does not necessarily guarantee that data appended by + /// different processes or threads does not interleave. The amount of data accepted a + /// single `write()` call depends on the operating system and file system. A + /// successful `write()` is allowed to write only part of the given data, so even if + /// you're careful to provide the whole message in a single call to `write()`, there + /// is no guarantee that it will be written out in full. If you rely on the filesystem + /// accepting the message in a single write, make sure that all data that belongs + /// together is written in one operation. This can be done by concatenating strings + /// before passing them to [`write()`]. /// /// If a file is opened with both read and append access, beware that after /// opening, and after every write, the position for reading may be set at the @@ -1003,6 +1009,9 @@ impl OpenOptions { /// [`write()`]: Write::write "io::Write::write" /// [`flush()`]: Write::flush "io::Write::flush" /// [stream_position]: Seek::stream_position "io::Seek::stream_position" + /// [seek]: Seek::seek "io::Seek::seek" + /// [Current]: SeekFrom::Current "io::SeekFrom::Current" + /// [End]: SeekFrom::End "io::SeekFrom::End" /// /// # Examples /// diff --git a/library/std/src/sys/pal/unix/process/process_unix.rs b/library/std/src/sys/pal/unix/process/process_unix.rs index e798510f9e6..d65657790c4 100644 --- a/library/std/src/sys/pal/unix/process/process_unix.rs +++ b/library/std/src/sys/pal/unix/process/process_unix.rs @@ -11,18 +11,6 @@ use crate::os::linux::process::PidFd; #[cfg(target_os = "linux")] use crate::os::unix::io::AsRawFd; -#[cfg(any( - target_os = "macos", - target_os = "watchos", - target_os = "visionos", - target_os = "tvos", - target_os = "freebsd", - all(target_os = "linux", target_env = "gnu"), - all(target_os = "linux", target_env = "musl"), - target_os = "nto", -))] -use crate::sys::weak::weak; - #[cfg(target_os = "vxworks")] use libc::RTP_ID as pid_t; @@ -466,6 +454,7 @@ impl Command { envp: Option<&CStringArray>, ) -> io::Result<Option<Process>> { use crate::mem::MaybeUninit; + use crate::sys::weak::weak; use crate::sys::{self, cvt_nz, unix_sigpipe_attr_specified}; if self.get_gid().is_some() |
