File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -241,6 +241,7 @@ impl RunnerFifo {
241241
242242 let is_alive = health_check ( ) . await ?;
243243 if !is_alive {
244+ info ! ( "Process terminated, stopping the command handler" ) ;
244245 break ;
245246 }
246247 }
Original file line number Diff line number Diff line change @@ -254,18 +254,27 @@ impl PerfRunner {
254254 let mut symbols_by_pid = HashMap :: < pid_t , ProcessSymbols > :: new ( ) ;
255255 let mut unwind_data_by_pid = HashMap :: < pid_t , Vec < UnwindData > > :: new ( ) ;
256256
257+ // The runner spawns a `bash` process, which will execute perf and the benchmark. To check if it
258+ // terminated, we have to check if all the sub-processes terminated.
259+ // We can't check for the `bash` process, because it will terminate after the FIFO handler has
260+ // finished (because we're using a single-threaded runtime).
261+ let mut sys = sysinfo:: System :: new ( ) ;
257262 let health_check = async || {
258- let res = unsafe { libc:: kill ( pid, 0 ) } ;
259- if res == 0 {
260- return Ok ( true ) ;
261- }
263+ sys. refresh_processes ( sysinfo:: ProcessesToUpdate :: All , true ) ;
264+ let process = sys. process ( sysinfo:: Pid :: from_u32 ( pid as u32 ) ) ;
265+
266+ match process {
267+ None => Ok ( false ) ,
268+ Some ( _proc) => {
269+ let has_children = sys. processes ( ) . values ( ) . any ( |p| {
270+ p. parent ( )
271+ . map ( |parent_pid| parent_pid. as_u32 ( ) == pid as u32 )
272+ . unwrap_or ( false )
273+ } ) ;
262274
263- let err = std:: io:: Error :: last_os_error ( ) ;
264- if err. raw_os_error ( ) == Some ( libc:: ESRCH ) {
265- return Ok ( false ) ;
275+ Ok ( has_children)
276+ }
266277 }
267-
268- Ok ( true )
269278 } ;
270279
271280 let on_cmd = async |cmd : & FifoCommand | {
You can’t perform that action at this time.
0 commit comments