MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / pgrp_pseudoterminal

Function pgrp_pseudoterminal

tests/termios/pgrp.rs:26–55  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

24#[cfg(feature = "pty")]
25#[test]
26fn pgrp_pseudoterminal() {
27 use rustix::pty::*;
28 use rustix::termios::*;
29
30 let pty = match openpt(OpenptFlags::NOCTTY) {
31 Ok(pty) => pty,
32 Err(rustix::io::Errno::NOSYS) => return,
33 Err(err) => panic!("{:?}", err),
34 };
35
36 // Linux's `tcgetpgrp` returns 0 here, which is not documented, so rustix
37 // translates it into `OPNOTSUPP`.
38 #[cfg(linux_kernel)]
39 assert_eq!(tcgetpgrp(&pty), Err(rustix::io::Errno::OPNOTSUPP));
40
41 // FreeBSD's `tcgetpgrp` returns 100000 here, or presumably some other
42 // number if that number is already taken, which is documented behavior,
43 // but impossible to test for reliably.
44 #[cfg(not(linux_kernel))]
45 assert!(matches!(tcgetpgrp(&pty), Ok(_)));
46
47 // We shouldn't be able to set the process group to [`Pid::INIT`].
48 match tcsetpgrp(&pty, rustix::termios::Pid::INIT).unwrap_err() {
49 #[cfg(freebsdlike)]
50 rustix::io::Errno::PERM => {}
51 #[cfg(any(apple, linux_kernel))]
52 rustix::io::Errno::NOTTY => {}
53 err => panic!("{:?}", err),
54 }
55}

Callers

nothing calls this directly

Calls 2

openptFunction · 0.50
tcsetpgrpFunction · 0.50

Tested by

no test coverage detected