@@ -550,14 +550,14 @@ class Launcher : public PluginHost::IPlugin {
550550 public:
551551 Job (Config* config, const Time& interval, Exchange::IMemory* memory)
552552 : _adminLock()
553- , _pid(0 )
554553 , _options(config->Command.Value().c_str())
555554 , _process(false )
556555 , _memory(memory)
557556 , _interval(interval)
558557 , _closeTime(config->CloseTime.Value())
559558 , _shutdownPhase(0 )
560559 , _processListEmpty(1 , 1 )
560+ , _shutdownCompleted(false )
561561 {
562562 auto iter = config->Parameters .Elements ();
563563
@@ -604,7 +604,7 @@ class Launcher : public PluginHost::IPlugin {
604604 _processList.push_back (info.ChildId ());
605605
606606 if (_shutdownPhase == 2 ) {
607- ::kill (pid , SIGKILL);
607+ ::kill (info.ChildId() , SIGKILL);
608608 }
609609 }
610610
@@ -617,15 +617,15 @@ class Launcher : public PluginHost::IPlugin {
617617
618618 ProcessList::iterator position (std::find (_processList.begin (), _processList.end (), info.Id ()));
619619 if (position != _processList.end ()) {
620- _position .erase (position);
621- if ( (_position .Id () == _pid ) && (_process.IsActive () == false ) ) {
620+ _processList .erase (position);
621+ if ( (info .Id () ==_processList. front () ) && (_process.IsActive () == false ) ) {
622622 _memory->Observe (0 );
623623 }
624624 else {
625625 // TODO: Probably might need to add the read exit code here for any process that exits to prevent
626626 // Zombie processes here..
627627 }
628- if (_position .size () == 0 ) {
628+ if (_processList .size () == 0 ) {
629629 _processListEmpty.Unlock ();
630630 }
631631 }
@@ -672,6 +672,7 @@ class Launcher : public PluginHost::IPlugin {
672672 }
673673
674674 _adminLock.Unlock ();
675+ _process.WaitProcessCompleted (1000 );
675676 }
676677
677678 if (_processListEmpty.Lock (1000 ) != Core::ERROR_NONE) {
@@ -692,18 +693,18 @@ class Launcher : public PluginHost::IPlugin {
692693 Core::Time nextRun (Core::Time::Now ());
693694
694695 // Check if the process is not active, no need to reschedule the same job again.
695- if ( (_process.IsActive () == false ) && (_shutdownCompleted.Lock (0 ) ! = Core::ERROR_NONE) ) {
696+ if ( (_process.IsActive () == false ) && (_shutdownCompleted.Lock (0 ) = = Core::ERROR_NONE) ) {
696697
697698 ASSERT (_processList.size () == 0 );
698699
699700 _processList.push_back (0 );
700-
701701 _process.Launch (_options, &_processList.front ());
702702
703703 TRACE (Trace::Information, (_T (" Launched command: %s [%d]." ), _options.Command ().c_str (), Pid ()));
704704 ASSERT (_memory != nullptr );
705705
706706 _memory->Observe (Pid ());
707+ _shutdownCompleted.Unlock ();
707708 }
708709
709710 if (_interval.IsValid () == true ) {
@@ -726,7 +727,8 @@ class Launcher : public PluginHost::IPlugin {
726727 uint8_t _closeTime;
727728 uint8_t _shutdownPhase;
728729 ProcessList _processList;
729- Core::BinairySamaphore _shutdownCompleted;
730+ Core::Event _processListEmpty;
731+ Core::BinairySemaphore _shutdownCompleted;
730732 };
731733
732734public:
0 commit comments