]> _ Git - cubist_util.git/commitdiff
.
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 18 May 2022 20:08:22 +0000 (22:08 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 18 May 2022 20:08:22 +0000 (22:08 +0200)
src/CommandLine.php

index 8572925f5f004a7ba126131d21783f82ff8f0e56..95cfe940f05997d31afc4595d2127864f6df275b 100644 (file)
@@ -20,6 +20,7 @@ class CommandLine
     protected $lang;
     protected $ssh = null;
     protected $longArgSeparator = '=';
+    protected $timeout = 0;
 
     function __construct($program, $output = null, $error = true)
     {
@@ -196,6 +197,10 @@ class CommandLine
             }
         }
 
+        if ($this->getTimeout() > 0) {
+            $commande = 'timeout ' . $this->getTimeout() . ' ' . $commande;
+        }
+
         if ($this->nohup) {
             $commande = 'nohup ' . $commande;
         }
@@ -275,4 +280,20 @@ class CommandLine
         return $this->commande;
     }
 
+    /**
+     * @return int
+     */
+    public function getTimeout(): int
+    {
+        return $this->timeout;
+    }
+
+    /**
+     * @param int $timeout
+     */
+    public function setTimeout(int $timeout): void
+    {
+        $this->timeout = $timeout;
+    }
+
 }