rust/library/std/src/sys/pal
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
..
common std: update internal uses of io::const_error! 2024-11-26 18:38:24 +01:00
hermit Constify SystemTime methods 2025-08-12 14:05:47 -04:00
itron Print thread ID in panic message if thread name is unknown 2025-08-06 23:59:47 +00:00
sgx Constify SystemTime methods 2025-08-12 14:05:47 -04:00
solid Constify SystemTime methods 2025-08-12 14:05:47 -04:00
teeos Print thread ID in panic message if thread name is unknown 2025-08-06 23:59:47 +00:00
trusty Combine env consts into std::sys::env_consts 2025-04-18 19:17:08 -07:00
uefi Rollup merge of #145025 - lolbinarycat:ci-tidy-spellcheck, r=Kobzol 2025-08-19 19:42:07 +08:00
unix Rollup merge of #137494 - nabijaczleweli:dup, r=Mark-Simulacrum 2025-08-21 17:57:48 -04:00
unsupported Constify SystemTime methods 2025-08-12 14:05:47 -04:00
wasi library: Migrate from cfg_if to cfg_select 2025-08-16 05:28:31 -07:00
wasip2 Combine env consts into std::sys::env_consts 2025-04-18 19:17:08 -07:00
wasm library: Migrate from cfg_if to cfg_select 2025-08-16 05:28:31 -07:00
windows Auto merge of #145489 - joshtriplett:cfg-if-not, r=Amanieu 2025-08-18 19:37:33 +00:00
xous Constify SystemTime methods 2025-08-12 14:05:47 -04:00
zkvm Rollup merge of #140143 - thaliaarchi:move-env-pal, r=joboet 2025-04-25 07:50:25 +02:00
mod.rs library: Migrate from cfg_if to cfg_select 2025-08-16 05:28:31 -07:00