summaryrefslogtreecommitdiff
path: root/simpleperf/workload.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'simpleperf/workload.cpp')
-rw-r--r--simpleperf/workload.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/simpleperf/workload.cpp b/simpleperf/workload.cpp
index b3bd459f..4aaeb2a9 100644
--- a/simpleperf/workload.cpp
+++ b/simpleperf/workload.cpp
@@ -51,10 +51,22 @@ bool Workload::RunCmd(const std::vector<std::string>& args, bool report_error) {
return ret == 0;
}
+Workload::Workload(const std::vector<std::string>& args, const std::function<void ()>& function)
+ : work_state_(NotYetCreateNewProcess),
+ child_proc_args_(args),
+ child_proc_function_(function),
+ work_pid_(-1),
+ start_signal_fd_(-1),
+ exec_child_fd_(-1) {
+ kill_function_ = [](pid_t pid) {
+ kill(pid, SIGKILL);
+ };
+}
+
Workload::~Workload() {
if (work_pid_ != -1 && work_state_ != NotYetCreateNewProcess) {
if (!Workload::WaitChildProcess(false, false, nullptr)) {
- kill(work_pid_, SIGKILL);
+ kill_function_(work_pid_);
Workload::WaitChildProcess(true, true, nullptr);
}
}