@@ -151,7 +151,9 @@ pub struct PtyInstance {
151151 pub master : Arc < Mutex < Box < dyn MasterPty + Send > > > ,
152152 pub writer : Arc < Mutex < Box < dyn Write + Send > > > ,
153153 /// PID of the login shell itself. When the tty's foreground process group
154- /// leader differs from this, the user is running something.
154+ /// leader differs from this, the user is running something. Unread on
155+ /// Windows, where there are no process groups to compare it against.
156+ #[ cfg_attr( windows, allow( dead_code) ) ]
155157 shell_pid : Option < u32 > ,
156158 shutdown : Arc < Mutex < bool > > ,
157159}
@@ -257,13 +259,28 @@ impl PtyInstance {
257259 /// `None` means idle (or undeterminable, which is treated as idle: a false
258260 /// "busy" would block updating forever, while a false "idle" only costs the
259261 /// user a confirmation they'd have clicked through anyway).
262+ #[ cfg( unix) ]
260263 pub fn foreground_pid ( & self ) -> Option < u32 > {
261264 let shell_pid = self . shell_pid ?;
262265 let master = self . master . lock ( ) . ok ( ) ?;
263266 let leader = master. process_group_leader ( ) ? as u32 ;
264267 ( leader != shell_pid) . then_some ( leader)
265268 }
266269
270+ /// Always `None` on Windows.
271+ ///
272+ /// The question doesn't exist there: ConPTY has no process groups, and
273+ /// `portable-pty` reflects that by declaring `process_group_leader` only
274+ /// under `#[cfg(unix)]` — so this isn't a stub for something unimplemented,
275+ /// it's the whole answer the platform can give.
276+ ///
277+ /// Callers read `None` as idle, which errs the safe way: the update flow
278+ /// simply won't name a running command before restarting.
279+ #[ cfg( windows) ]
280+ pub fn foreground_pid ( & self ) -> Option < u32 > {
281+ None
282+ }
283+
267284 pub fn write ( & self , data : & [ u8 ] ) -> Result < ( ) , String > {
268285 let mut writer = self . writer . lock ( ) . map_err ( |e| e. to_string ( ) ) ?;
269286 writer. write_all ( data) . map_err ( |e| format ! ( "Write failed: {}" , e) ) ?;
0 commit comments