From f998f0de2a4d2fda80bca12f8adb74557e814059 Mon Sep 17 00:00:00 2001
From: Sylvestre Ho <sho@merethis.com>
Date: Mon, 8 Jul 2013 16:40:14 +0200
Subject: [PATCH] refs #4504; +timeout on ssh

---
 bin/centcore | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/bin/centcore b/bin/centcore
index b7d287488e..8bec1636de 100644
--- a/bin/centcore
+++ b/bin/centcore
@@ -403,7 +403,15 @@ sub sendExternalCommand($$){
         } else {
             writeLogFile("External command : ".$server_info->{'ns_ip_address'}." ($id) : \"".$cmd."\"");
             my $cmd = "$ssh -q ". $server_info->{'ns_ip_address'} ." -p $port 'echo \"".$cmd."\" >> ".$command_file."'\n";
-            $stdout = `$cmd`;
+            eval {
+                local $SIG{ALRM} = sub { die "alarm\n" };
+                alarm $timeout;
+                $stdout = `$cmd`;
+                alarm 0;
+            };
+            if ($@) {
+                writeLogFile("Could not write into pipe file ".$command_file." on poller ".$server_info->{'ns_ip_address'}."\n");
+            }
         }
 
         if (defined($stdout) && $stdout){
-- 
GitLab