@@ -697,6 +697,11 @@ std::shared_ptr<CommandExecute> CommandAgent::PrepareCommandExecute(const std::s
697
697
break ;
698
698
}
699
699
700
+ if (message->GetTimeout ().has_value ())
701
+ {
702
+ retval->m_timeout = *message->GetTimeout ();
703
+ }
704
+
700
705
if (m_bChildDebug)
701
706
{
702
707
Log::Debug (L" CommandAgent: Configured dump file path '{}'" , m_TempDir);
@@ -780,6 +785,17 @@ HRESULT CommandAgent::ExecuteNextCommand()
780
785
781
786
if (SUCCEEDED (hr))
782
787
{
788
+ if (command->GetTimeout ().has_value () && command->GetTimeout ()->count () != 0 )
789
+ {
790
+ auto timer = std::make_shared<Concurrency::timer<CommandMessage::Message>>(
791
+ (unsigned int )command->GetTimeout ()->count (),
792
+ CommandMessage::MakeAbortMessage (command->GetProcessHandle ()),
793
+ static_cast <CommandMessage::ITarget*>(&m_cmdAgentBuffer));
794
+
795
+ command->SetTimeoutTimer (timer);
796
+ timer->start ();
797
+ }
798
+
783
799
{
784
800
Concurrency::critical_section::scoped_lock s (m_cs);
785
801
m_RunningCommands.push_back (command);
@@ -1271,6 +1287,15 @@ void CommandAgent::run()
1271
1287
}
1272
1288
}
1273
1289
break ;
1290
+ case CommandMessage::Abort: {
1291
+ Log::Info (" Abort process" );
1292
+
1293
+ if (!TerminateProcess (request->ProcessHandle (), E_ABORT))
1294
+ {
1295
+ Log::Error (L" Failed to terminate process [{}]" , LastWin32Error ());
1296
+ }
1297
+ }
1298
+ break ;
1274
1299
case CommandMessage::TerminateAll: {
1275
1300
Log::Critical (L" Kill all running tasks: {}" , m_Keyword);
1276
1301
0 commit comments