perf trace: Avoid early exit due to running SIGCHLD handler before it makes sense to

When running 'perf trace' with an BPF object like:

# perf trace -e openat,tools/perf/examples/bpf/hello.c

the event parsing eventually calls llvm__get_kbuild_opts() that runs a
script and that ends up with SIGCHLD delivered to the 'perf trace'
handler, which assumes the workload process is done and quits 'perf
trace'.

Move the SIGCHLD handler setup directly to trace__run(), where the event
is parsed and the object is already compiled.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Christy Lee <christyc.y.lee@gmail.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20220106222030.227499-1-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by Jiri Olsa and committed by Arnaldo Carvalho de Melo f06a82f9 24556728

Changed files
+1 -1
tools
+1 -1
tools/perf/builtin-trace.c
··· 3925 3925 bool draining = false; 3926 3926 3927 3927 trace->live = true; 3928 + signal(SIGCHLD, sig_handler); 3928 3929 3929 3930 if (!trace->raw_augmented_syscalls) { 3930 3931 if (trace->trace_syscalls && trace__add_syscall_newtp(trace)) ··· 4874 4873 4875 4874 signal(SIGSEGV, sighandler_dump_stack); 4876 4875 signal(SIGFPE, sighandler_dump_stack); 4877 - signal(SIGCHLD, sig_handler); 4878 4876 signal(SIGINT, sig_handler); 4879 4877 4880 4878 trace.evlist = evlist__new();