Register Subprocess timer callbacks prior to OnRun()
This prevents dangling pointers in cases where a Subprocess instance is
created/destroyed prior to EventLoop creation.
Change-Id: Id3a6db20353955da59b912ca555ab561ee18b4c1
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/starter/subprocess.cc b/aos/starter/subprocess.cc
index f5563e6..faa1873 100644
--- a/aos/starter/subprocess.cc
+++ b/aos/starter/subprocess.cc
@@ -151,13 +151,11 @@
event_loop_->AddTimer([this]() { MaybeHandleSignal(); })),
on_change_({on_change}),
quiet_flag_(quiet_flag) {
- event_loop_->OnRun([this]() {
- // Every second poll to check if the child is dead. This is used as a
- // default for the case where the user is not directly catching SIGCHLD and
- // calling MaybeHandleSignal for us.
- child_status_handler_->Schedule(event_loop_->monotonic_now(),
- std::chrono::seconds(1));
- });
+ // Every second poll to check if the child is dead. This is used as a
+ // default for the case where the user is not directly catching SIGCHLD and
+ // calling MaybeHandleSignal for us.
+ child_status_handler_->Schedule(event_loop_->monotonic_now(),
+ std::chrono::seconds(1));
}
Application::Application(const aos::Application *application,