Skip to content

Commit cb77fcb

Browse files
Rollup merge of rust-lang#152133 - Enselic:on-broken-pipe-flag-rename, r=ChrisDenton
library/std: Rename `ON_BROKEN_PIPE_FLAG_USED` to `ON_BROKEN_PIPE_USED` This commit is a pure internal rename and does not change any functionality. The `FLAG_` part of `ON_BROKEN_PIPE_FLAG_USED` comes from that the compiler flag `-Zon-broken-pipe=...` is used to enable the feature. Remove the `FLAG_` part so the name works both for the current compiler flag `-Zon-broken-pipe=...` and for the upcoming [Externally Implementable Item `#[std::io::on_broken_pipe]`](rust-lang#150591) PR. This makes the diff of that PR smaller. The local variable name `sigpipe_attr_specified` comes from way back when the feature was controlled with an `fn main()` attribute called `#[unix_sigpipe = "..."]`. Rename that too.
2 parents 3c61714 + 01c0c14 commit cb77fcb

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

library/std/src/sys/pal/unix/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,15 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
169169
pub const SIG_DFL: u8 = 3;
170170
}
171171

172-
let (sigpipe_attr_specified, handler) = match sigpipe {
172+
let (on_broken_pipe_used, handler) = match sigpipe {
173173
sigpipe::DEFAULT => (false, Some(libc::SIG_IGN)),
174174
sigpipe::INHERIT => (true, None),
175175
sigpipe::SIG_IGN => (true, Some(libc::SIG_IGN)),
176176
sigpipe::SIG_DFL => (true, Some(libc::SIG_DFL)),
177177
_ => unreachable!(),
178178
};
179-
if sigpipe_attr_specified {
180-
ON_BROKEN_PIPE_FLAG_USED.store(true, crate::sync::atomic::Ordering::Relaxed);
179+
if on_broken_pipe_used {
180+
ON_BROKEN_PIPE_USED.store(true, crate::sync::atomic::Ordering::Relaxed);
181181
}
182182
if let Some(handler) = handler {
183183
rtassert!(signal(libc::SIGPIPE, handler) != libc::SIG_ERR);
@@ -199,7 +199,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
199199
target_os = "vxworks",
200200
target_os = "vita",
201201
)))]
202-
static ON_BROKEN_PIPE_FLAG_USED: crate::sync::atomic::Atomic<bool> =
202+
static ON_BROKEN_PIPE_USED: crate::sync::atomic::Atomic<bool> =
203203
crate::sync::atomic::AtomicBool::new(false);
204204

205205
#[cfg(not(any(
@@ -211,8 +211,8 @@ static ON_BROKEN_PIPE_FLAG_USED: crate::sync::atomic::Atomic<bool> =
211211
target_os = "vita",
212212
target_os = "nuttx",
213213
)))]
214-
pub(crate) fn on_broken_pipe_flag_used() -> bool {
215-
ON_BROKEN_PIPE_FLAG_USED.load(crate::sync::atomic::Ordering::Relaxed)
214+
pub(crate) fn on_broken_pipe_used() -> bool {
215+
ON_BROKEN_PIPE_USED.load(crate::sync::atomic::Ordering::Relaxed)
216216
}
217217

218218
// SAFETY: must be called only once during runtime cleanup.

library/std/src/sys/process/unix/unix.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ impl Command {
356356
// If -Zon-broken-pipe is not used, reset SIGPIPE to SIG_DFL for backward compatibility.
357357
//
358358
// -Zon-broken-pipe is an opportunity to change the default here.
359-
if !crate::sys::pal::on_broken_pipe_flag_used() {
359+
if !crate::sys::pal::on_broken_pipe_used() {
360360
#[cfg(target_os = "android")] // see issue #88585
361361
{
362362
let mut action: libc::sigaction = mem::zeroed();
@@ -455,7 +455,7 @@ impl Command {
455455
use core::sync::atomic::{Atomic, AtomicU8, Ordering};
456456

457457
use crate::mem::MaybeUninit;
458-
use crate::sys::{self, cvt_nz, on_broken_pipe_flag_used};
458+
use crate::sys::{self, cvt_nz, on_broken_pipe_used};
459459

460460
if self.get_gid().is_some()
461461
|| self.get_uid().is_some()
@@ -731,7 +731,7 @@ impl Command {
731731
// If -Zon-broken-pipe is not used, reset SIGPIPE to SIG_DFL for backward compatibility.
732732
//
733733
// -Zon-broken-pipe is an opportunity to change the default here.
734-
if !on_broken_pipe_flag_used() {
734+
if !on_broken_pipe_used() {
735735
let mut default_set = MaybeUninit::<libc::sigset_t>::uninit();
736736
cvt(sigemptyset(default_set.as_mut_ptr()))?;
737737
cvt(sigaddset(default_set.as_mut_ptr(), libc::SIGPIPE))?;

0 commit comments

Comments
 (0)