#include <linux/zalloc.h>
#include <sys/prctl.h>
#include <sys/resource.h>
+#include <sys/wait.h>
#include <inttypes.h>
#include <errno.h>
return 0;
}
+static volatile sig_atomic_t done;
+
static void sighandler(int sig __maybe_unused)
{
+ done = 1;
}
static int enable_sched_schedstats(int *reset)
.mode = PERF_DATA_MODE_WRITE,
};
+ done = 0;
signal(SIGINT, sighandler);
signal(SIGCHLD, sighandler);
signal(SIGTERM, sighandler);
if (argc)
evlist__start_workload(evlist);
- /* wait for signal */
- pause();
+ while (!done) {
+ if (argc && waitpid(evlist->workload.pid, NULL, WNOHANG) > 0)
+ break;
+ sleep(1);
+ }
if (reset) {
err = disable_sched_schedstat();