@@ -1536,13 +1536,20 @@ static size_t trace__fprintf_tstamp(struct trace *trace, u64 tstamp, FILE *fp)
1536
1536
return fprintf (fp , " ? " );
1537
1537
}
1538
1538
1539
+ static pid_t workload_pid = -1 ;
1539
1540
static bool done = false;
1540
1541
static bool interrupted = false;
1541
1542
1542
- static void sig_handler (int sig )
1543
+ static void sighandler_interrupt (int sig __maybe_unused )
1543
1544
{
1544
- done = true;
1545
- interrupted = sig == SIGINT ;
1545
+ done = interrupted = true;
1546
+ }
1547
+
1548
+ static void sighandler_chld (int sig __maybe_unused , siginfo_t * info ,
1549
+ void * context __maybe_unused )
1550
+ {
1551
+ if (info -> si_pid == workload_pid )
1552
+ done = true;
1546
1553
}
1547
1554
1548
1555
static size_t trace__fprintf_comm_tid (struct trace * trace , struct thread * thread , FILE * fp )
@@ -3938,7 +3945,6 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
3938
3945
bool draining = false;
3939
3946
3940
3947
trace -> live = true;
3941
- signal (SIGCHLD , sig_handler );
3942
3948
3943
3949
if (!trace -> raw_augmented_syscalls ) {
3944
3950
if (trace -> trace_syscalls && trace__add_syscall_newtp (trace ))
@@ -4018,6 +4024,7 @@ static int trace__run(struct trace *trace, int argc, const char **argv)
4018
4024
fprintf (trace -> output , "Couldn't run the workload!\n" );
4019
4025
goto out_delete_evlist ;
4020
4026
}
4027
+ workload_pid = evlist -> workload .pid ;
4021
4028
}
4022
4029
4023
4030
err = evlist__open (evlist );
@@ -4887,10 +4894,16 @@ int cmd_trace(int argc, const char **argv)
4887
4894
const char * const trace_subcommands [] = { "record" , NULL };
4888
4895
int err = -1 ;
4889
4896
char bf [BUFSIZ ];
4897
+ struct sigaction sigchld_act ;
4890
4898
4891
4899
signal (SIGSEGV , sighandler_dump_stack );
4892
4900
signal (SIGFPE , sighandler_dump_stack );
4893
- signal (SIGINT , sig_handler );
4901
+ signal (SIGINT , sighandler_interrupt );
4902
+
4903
+ memset (& sigchld_act , 0 , sizeof (sigchld_act ));
4904
+ sigchld_act .sa_flags = SA_SIGINFO ;
4905
+ sigchld_act .sa_sigaction = sighandler_chld ;
4906
+ sigaction (SIGCHLD , & sigchld_act , NULL );
4894
4907
4895
4908
trace .evlist = evlist__new ();
4896
4909
trace .sctbl = syscalltbl__new ();
0 commit comments