]> _ Git - cubist_util.git/commitdiff
wip #7780 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 7 Oct 2025 10:30:28 +0000 (12:30 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 7 Oct 2025 10:30:28 +0000 (12:30 +0200)
src/CommandLine.php

index d6293d51e43c790b5d729b97405109e4e0ba715a..cf237d08a4331f035877c9a684f8b8c8ff6ea69f 100644 (file)
@@ -23,6 +23,7 @@ class CommandLine
     protected $ssh = null;
     protected $longArgSeparator = '=';
     protected $timeout = 0;
+    protected $cpulimit = 0;
     protected $sudo = false;
     protected $unique = false;
     protected $uniqueCommand = null;
@@ -266,6 +267,10 @@ class CommandLine
             $commande = 'timeout ' . $this->getTimeout() . ' ' . $commande;
         }
 
+        if ($this->getCPULimit() > 0) {
+            $commande = 'cpulimit -l ' . $this->getCPULimit() . ' ' . $commande;
+        }
+
         if ($this->nohup) {
             $commande = 'nohup ' . $commande;
         }
@@ -423,6 +428,22 @@ class CommandLine
         $this->unique = $unique;
     }
 
+    /**
+     * @param int $cpulimit
+     */
+    public function setCPULimit(int $cpulimit): void
+    {
+        $this->cpulimit = $cpulimit;
+    }
+
+    /**
+     * @return int
+     */
+    public function getCPULimit(): int
+    {
+        return $this->cpulimit;
+    }
+
     public function ddCommand()
     {
         $this->_preExecute();