◐ Shell
clean mode source ↗

impl os functions by youknowone · Pull Request #6484 · RustPython/RustPython

🧩 Analysis chain

🏁 Script executed:

# Find the setpgid function and its platform guards
rg -n "fn setpgid" crates/vm/src/stdlib/posix.rs -A5 -B5

Repository: RustPython/RustPython

Length of output: 511


🏁 Script executed:

# Also check for any #[cfg] guards on setpgrp function
rg -n "fn setpgrp" crates/vm/src/stdlib/posix.rs -A5 -B5

Repository: RustPython/RustPython

Length of output: 551


🏁 Script executed:

# Verify tcgetpgrp/tcsetpgrp guards as mentioned in review
rg -n "fn tcgetpgrp\|fn tcsetpgrp" crates/vm/src/stdlib/posix.rs -A3 -B3

Repository: RustPython/RustPython

Length of output: 47


🏁 Script executed:

# Search for tcgetpgrp and tcsetpgrp in the file
rg -n "tcgetpgrp\|tcsetpgrp" crates/vm/src/stdlib/posix.rs -B3 -A5

Repository: RustPython/RustPython

Length of output: 47


🏁 Script executed:

# Get more context around setpgrp to see the cfg guards applied
sed -n '1240,1260p' crates/vm/src/stdlib/posix.rs

Repository: RustPython/RustPython

Length of output: 791


🏁 Script executed:

# Check if setpgid has any cfg guards elsewhere or if it's conditionally available in nix crate
rg -n "#\[cfg" crates/vm/src/stdlib/posix.rs | grep -A2 -B2 "setpgid\|setpgrp" || rg -n "#\[cfg" crates/vm/src/stdlib/posix.rs | head -20

Repository: RustPython/RustPython

Length of output: 806


🏁 Script executed:

# Check all cfg guards around setpgid function
sed -n '1230,1250p' crates/vm/src/stdlib/posix.rs

Repository: RustPython/RustPython

Length of output: 853


🏁 Script executed:

# Check if setpgid is available on wasi/redox by searching nix crate availability
# First, let's look at what the nix crate's setpgid function definition supports
rg -n "setpgid\|setpgrp" crates/vm/src/stdlib/posix.rs -B1

Repository: RustPython/RustPython

Length of output: 47


🏁 Script executed:

# Search for nix::unistd imports to understand platform support
rg -n "use nix::unistd" crates/vm/src/stdlib/posix.rs

Repository: RustPython/RustPython

Length of output: 153


🏁 Script executed:

# Check if setpgid has any cfg guards that might be missing
rg -n "#\[pyfunction\]" crates/vm/src/stdlib/posix.rs | grep -B1 "setpgid\|setpgrp"

Repository: RustPython/RustPython

Length of output: 47


🏁 Script executed:

# Look at the nix crate's Cargo.toml to understand platform support
cat Cargo.lock | grep -A5 "name = \"nix\""

Repository: RustPython/RustPython

Length of output: 491


🏁 Script executed:

# Search for any test or conditional compilation related to setpgid/setpgrp
rg -n "setpgid|setpgrp" crates/vm/src/stdlib/posix.rs

Repository: RustPython/RustPython

Length of output: 634


🏁 Script executed:

# Check the full function signatures around setpgid to understand platform support
sed -n '1235,1275p' crates/vm/src/stdlib/posix.rs

Repository: RustPython/RustPython

Length of output: 1601


🏁 Script executed:

# Check the nix crate's source to see if setpgid is conditionally compiled
# First let's search online documentation or check if there's a Cargo.toml with features
cat Cargo.toml | head -50

Repository: RustPython/RustPython

Length of output: 1778


🏁 Script executed:

# Check if setpgid is available on all platforms or if nix crate provides it conditionally
# by looking at other platform-specific functions
rg -n "#\[cfg.*target_os" crates/vm/src/stdlib/posix.rs | head -30

Repository: RustPython/RustPython

Length of output: 1653


🏁 Script executed:

# Let's check if there are any imports or re-exports that might indicate setpgid availability
rg -n "use nix" crates/vm/src/stdlib/posix.rs

Repository: RustPython/RustPython

Length of output: 479


🏁 Script executed:

# Search web for nix crate setpgid platform support

Repository: RustPython/RustPython

Length of output: 47


🌐 Web query:

nix crate setpgid platform support wasi redox

💡 Result:

Short answer

  • nix provides nix::unistd::setpgid (process feature) for Unix targets. [1][2]
  • WASI is not a supported Unix target for the nix crate, so setpgid is not available on WASI. [2]
  • Redox (x86_64-unknown-redox) has appeared as a Tier‑3 target in the nix supported-targets list, but tier‑3 support is best‑effort and many Unix process APIs (like traditional setpgid semantics) may be missing or unimplemented on Redox. Test/verify on Redox if you need setpgid behavior. [3][1]

Sources

  • setpgid docs (nix::unistd::setpgid). [1]
  • nix crate overview / "Available on Unix only" and crate features. [2]
  • nix README / supported-targets showing x86_64-unknown-redox as Tier 3. [3]

Add platform guard to setpgrp function.

The setpgrp function uses unistd::setpgid, which is not available on WASI or Redox. The related functions setsid, tcgetpgrp, and tcsetpgrp are properly guarded with #[cfg(not(any(target_os = "wasi", target_os = "redox")))], but setpgrp lacks this guard and will cause compilation failures on unsupported platforms.