rust/library/std/src/sys
Jacob Pratt 0a0553e2e4
Rollup merge of #137494 - nabijaczleweli:dup, r=Mark-Simulacrum
libstd: init(): dup() subsequent /dev/nulls instead of opening them again

This will be faster, and also it deduplicates the code so win/win

The dup() is actually infallible here. But whatever.

Before:
```
poll([{fd=0, events=0}, {fd=1, events=0}, {fd=2, events=0}], 3, 0) = 1 ([{fd=2, revents=POLLNVAL}])
openat(AT_FDCWD, "/dev/null", O_RDWR)   = 2
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f5749313050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0

poll([{fd=0, events=0}, {fd=1, events=0}, {fd=2, events=0}], 3, 0) = 2 ([{fd=0, revents=POLLNVAL}, {fd=2, revents=POLLNVAL}])
openat(AT_FDCWD, "/dev/null", O_RDWR)   = 0
openat(AT_FDCWD, "/dev/null", O_RDWR)   = 2
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7efe12006050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0

poll([{fd=0, events=0}, {fd=1, events=0}, {fd=2, events=0}], 3, 0) = 3 ([{fd=0, revents=POLLNVAL}, {fd=1, revents=POLLNVAL}, {fd=2, revents=POLLNVAL}])
openat(AT_FDCWD, "/dev/null", O_RDWR)   = 0
openat(AT_FDCWD, "/dev/null", O_RDWR)   = 1
openat(AT_FDCWD, "/dev/null", O_RDWR)   = 2
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fc2dc7ca050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
```

After:
```
poll([{fd=0, events=0}, {fd=1, events=0}, {fd=2, events=0}], 3, 0) = 1 ([{fd=1, revents=POLLNVAL}])
openat(AT_FDCWD, "/dev/null", O_RDWR)   = 1
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f488a3fb050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0

poll([{fd=0, events=0}, {fd=1, events=0}, {fd=2, events=0}], 3, 0) = 2 ([{fd=1, revents=POLLNVAL}, {fd=2, revents=POLLNVAL}])
openat(AT_FDCWD, "/dev/null", O_RDWR)   = 1
dup(1)                                  = 2
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f1a8943c050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0

poll([{fd=0, events=0}, {fd=1, events=0}, {fd=2, events=0}], 3, 0) = 3 ([{fd=0, revents=POLLNVAL}, {fd=1, revents=POLLNVAL}, {fd=2, revents=POLLNVAL}])
openat(AT_FDCWD, "/dev/null", O_RDWR)   = 0
dup(0)                                  = 1
dup(0)                                  = 2
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f4e3a4c7050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
```
2025-08-21 17:57:48 -04:00
..
alloc library: Migrate from cfg_if to cfg_select 2025-08-16 05:28:31 -07:00
anonymous_pipe library: Migrate from cfg_if to cfg_select 2025-08-16 05:28:31 -07:00
args library: Migrate from cfg_if to cfg_select 2025-08-16 05:28:31 -07:00
env library: Migrate from cfg_if to cfg_select 2025-08-16 05:28:31 -07:00
fd library: Migrate from cfg_if to cfg_select 2025-08-16 05:28:31 -07:00
fs Add flock support for cygwin 2025-08-21 01:06:51 +08:00
io library: Migrate from cfg_if to cfg_select 2025-08-16 05:28:31 -07:00
net library: Migrate from cfg_if to cfg_select 2025-08-16 05:28:31 -07:00
os_str library: Migrate from cfg_if to cfg_select 2025-08-16 05:28:31 -07:00
pal Rollup merge of #137494 - nabijaczleweli:dup, r=Mark-Simulacrum 2025-08-21 17:57:48 -04:00
path library: Migrate from cfg_if to cfg_select 2025-08-16 05:28:31 -07:00
personality library: Migrate from cfg_if to cfg_select 2025-08-16 05:28:31 -07:00
process library: Migrate from cfg_if to cfg_select 2025-08-16 05:28:31 -07:00
random library: Migrate from cfg_if to cfg_select 2025-08-16 05:28:31 -07:00
stdio library: Migrate from cfg_if to cfg_select 2025-08-16 05:28:31 -07:00
sync library: Migrate from cfg_if to cfg_select 2025-08-16 05:28:31 -07:00
thread_local library: Migrate from cfg_if to cfg_select 2025-08-16 05:28:31 -07:00
backtrace.rs Add experimental backtrace-trace-only std feature 2025-07-14 11:52:17 +00:00
cmath.rs library: Migrate from cfg_if to cfg_select 2025-08-16 05:28:31 -07:00
configure_builtins.rs Dynamically enable LSE for aarch64 rust provided intrinsics 2025-08-05 10:35:13 -05:00
env_consts.rs Move zkVM constants into sys::env_consts 2025-04-21 21:05:04 -07:00
exit_guard.rs library: Migrate from cfg_if to cfg_select 2025-08-16 05:28:31 -07:00
mod.rs tidy now installs typos-cli as-needed via cargo 2025-08-16 13:36:29 -05:00