[BUG] perf stat: hangs with -p and process completes

From: Stephane Eranian
Date: Fri Oct 12 2018 - 17:26:24 EST


Hi,

I am running into a perf stat issue with the -p option which allows you
to attach to a running process. If that process happens to terminate
while under monitoring
perf hangs in there and never terminates. The proper behavior would be to stop.
I can see the issue in that the attached process is not a child, so
wait() would not work.

To reproduce:
$ sleep 10 &
$ perf stat -p $!

doing the same with perf record works, so there is a solution to this problem.