File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed
Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ pub(in crate::exec) fn exec_pty(
105105 // FIXME: Here's where we should intercept the IO streams if we want to implement IO logging.
106106 // FIXME: ogsudo creates pipes for the IO streams and uses events to read from the strams to
107107 // the pipes. Investigate why.
108- if !io:: stdin ( ) . is_terminal_for_pgrp ( parent_pgrp) ? {
108+ if !io:: stdin ( ) . is_terminal_for_pgrp ( parent_pgrp) {
109109 dev_info ! ( "stdin is not a terminal, command will inherit it" ) ;
110110 if io:: stdin ( ) . is_pipe ( ) {
111111 exec_bg = true ;
@@ -120,7 +120,7 @@ pub(in crate::exec) fn exec_pty(
120120 }
121121 }
122122
123- if !io:: stdout ( ) . is_terminal_for_pgrp ( parent_pgrp) ? {
123+ if !io:: stdout ( ) . is_terminal_for_pgrp ( parent_pgrp) {
124124 dev_info ! ( "stdout is not a terminal, command will inherit it" ) ;
125125 if io:: stdout ( ) . is_pipe ( ) {
126126 exec_bg = true ;
@@ -129,7 +129,7 @@ pub(in crate::exec) fn exec_pty(
129129 command. stdout ( Stdio :: inherit ( ) ) ;
130130 }
131131
132- if !io:: stderr ( ) . is_terminal_for_pgrp ( parent_pgrp) ? {
132+ if !io:: stderr ( ) . is_terminal_for_pgrp ( parent_pgrp) {
133133 dev_info ! ( "stderr is not a terminal, command will inherit it" ) ;
134134 command. stderr ( Stdio :: inherit ( ) ) ;
135135 }
Original file line number Diff line number Diff line change @@ -176,7 +176,7 @@ mod sealed {
176176}
177177
178178pub ( crate ) trait Terminal : sealed:: Sealed {
179- fn is_terminal_for_pgrp ( & self , pgrp : ProcessId ) -> io :: Result < bool > ;
179+ fn is_terminal_for_pgrp ( & self , pgrp : ProcessId ) -> bool ;
180180 fn tcgetpgrp ( & self ) -> io:: Result < ProcessId >
181181 where
182182 Self : sealed:: SafeTty ;
@@ -196,14 +196,16 @@ pub(crate) trait Terminal: sealed::Sealed {
196196impl < F : AsFd > Terminal for F {
197197 /// Check if the foreground process group ID associated with this terminal is `pgrp`.
198198 /// Returns false if this is not actually a terminal.
199- fn is_terminal_for_pgrp ( & self , pgrp : ProcessId ) -> io :: Result < bool > {
199+ fn is_terminal_for_pgrp ( & self , pgrp : ProcessId ) -> bool {
200200 if !safe_isatty ( self . as_fd ( ) ) {
201- return Ok ( false ) ;
201+ return false ;
202202 }
203203
204204 // SAFETY: tcgetpgrp cannot cause UB
205- let id = cerr ( unsafe { libc:: tcgetpgrp ( self . as_fd ( ) . as_raw_fd ( ) ) } ) ?;
206- Ok ( ProcessId :: new ( id) == pgrp)
205+ let Ok ( id) = cerr ( unsafe { libc:: tcgetpgrp ( self . as_fd ( ) . as_raw_fd ( ) ) } ) else {
206+ return false ;
207+ } ;
208+ ProcessId :: new ( id) == pgrp
207209 }
208210 /// Get the foreground process group ID associated with this terminal.
209211 fn tcgetpgrp ( & self ) -> io:: Result < ProcessId > {
You can’t perform that action at this time.
0 commit comments