@@ -59,9 +59,9 @@ SERVICE_REGISTRATION(Launcher, 1, 0);
5959 ASSERT (_activity.IsValid () == true );
6060
6161 _memory->Observe (0 );
62- _observer.Unregister (&_notification);
6362
6463 _activity->Shutdown ();
64+ _observer.Unregister (&_notification);
6565 _activity.Release ();
6666
6767 _memory->Release ();
@@ -84,21 +84,47 @@ void Launcher::Update(const ProcessObserver::Info& info)
8484
8585 // This can potentially be called on a socket thread, so the deactivation (wich in turn kills this object) must be done
8686 // on a seperate thread. Also make sure this call-stack can be unwound before we are totally destructed.
87- if ( (_activity->Pid () == info.Id ()) && (info.Event () == ProcessObserver::Info::EVENT_EXIT) ) {
88-
89- _memory->Observe (0 );
90- uint32_t result = _activity->ExitCode ();
91-
92- if (result != Core::ERROR_NONE) {
93- SYSLOG (Trace::Fatal, (_T (" FORCED Shutdown: %s by error: %d." ), _service->Callsign ().c_str (), result));
94- PluginHost::WorkerPool::Instance ().Submit (PluginHost::IShell::Job::Create (_service, PluginHost::IShell::DEACTIVATED, PluginHost::IShell::FAILURE));
95- }
96- else if (_activity->Continuous () == false ) {
97- TRACE (Trace::Information, (_T (" Launcher [%s] has run succesfully, deactivation requested." ), _service->Callsign ().c_str ()));
98- PluginHost::WorkerPool::Instance ().Submit (PluginHost::IShell::Job::Create (_service, PluginHost::IShell::DEACTIVATED, PluginHost::IShell::AUTOMATIC));
87+ if (_activity->HasPid (info.Id ()) == true ) {
88+
89+ switch (info.Event ()) {
90+ case ProcessObserver::Info::EVENT_FORK:
91+ TRACE (Trace::Information, (_T (" FORK: parent tid=%d pid=%d -> child tid=%d pid=%d\n " ), info.Id (), info.Group (), info.ChildId (), info.ChildGroup ()));
92+ if (_activity->ShutdownInProgress () == false ) {
93+ _activity->AddPid (info.ChildId ());
94+ } else {
95+ _activity->Kill (info.ChildId ());
96+ }
97+ break ;
98+ case ProcessObserver::Info::EVENT_EXEC:
99+ TRACE (Trace::Information, (_T (" EXEC: tid=%d pid=%d\n " ), info.Id (), info.Group ()));
100+ break ;
101+ case ProcessObserver::Info::EVENT_EXIT:
102+ {
103+ if (_activity->Pid () == info.Id ()) {
104+ _memory->Observe (0 );
105+ uint32_t result = _activity->ExitCode ();
106+
107+ if (result != Core::ERROR_NONE) {
108+ SYSLOG (Trace::Fatal, (_T (" FORCED Shutdown: %s by error: %d." ), _service->Callsign ().c_str (), result));
109+ if (_activity->ShutdownInProgress () == false ) {
110+ PluginHost::WorkerPool::Instance ().Submit (PluginHost::IShell::Job::Create (_service, PluginHost::IShell::DEACTIVATED, PluginHost::IShell::FAILURE));
111+ }
112+ }
113+ else if (_activity->Continuous () == false ) {
114+ TRACE (Trace::Information, (_T (" Launcher [%s] has run succesfully, deactivation requested." ), _service->Callsign ().c_str ()));
115+ PluginHost::WorkerPool::Instance ().Submit (PluginHost::IShell::Job::Create (_service, PluginHost::IShell::DEACTIVATED, PluginHost::IShell::AUTOMATIC));
116+ }
117+ else {
118+ TRACE (Trace::Information, (_T (" Launcher [%s] has run succesfully, scheduled for the next run." ), _service->Callsign ().c_str ()));
119+ }
120+ } else {
121+ _activity->RemovePid (info.Id ());
122+ }
123+ break ;
99124 }
100- else {
101- TRACE (Trace::Information, (_T (" Launcher [%s] has run succesfully, scheduled for the next run." ), _service->Callsign ().c_str ()));
125+ default :
126+ printf (" unhandled proc event\n " );
127+ break ;
102128 }
103129 }
104130}
@@ -125,6 +151,7 @@ bool Launcher::ScheduleParameters(const Config& config, string& message, Core::T
125151 }
126152 else if ( (timeMode == ABSOLUTE_WITH_INTERVAL) && ((interval.IsValid () == false ) || (interval.TimeInSeconds () == 0 )) ) {
127153 message = _T (" Requested mode is ABSOLUTE WITH INTERVAL but no interval (or 0 second interval) is given." );
154+
128155 }
129156 else {
130157 // All signals green, we have valid input, calculate the ScheduleTime/Interval time
0 commit comments