Hello all,

Is there a way to limit the memory consumption and / or the CPU
consumption of processes launched by the php functions system,
exec, passthru, proc_open and shell_exec?

We use mod_php with an apache (mpm-prefork) on Linux.

The following settings don't have any effect at all:
PHP:
  max_execution_time 30
  memory_limit 8M
Apache:
  RLimitCPU 30 30
  RLimitMEM 8388608 8388608

The limits above do have effect on php-scripts (without system calls)
and on CGIs (as well on processes launched by CGIs).

Any Ideas?

Kind Regards
valli


PS: I tested it with the following two scripts:
system_memorytest.php
=====================
<html>
<head>
  <title>php-systemcall-memory test</title>
</head>
<body>
  php-systemcall-memory test<br>
  ... and here's the system call:<br>
  <pre>
<?php
   $cmd = '/usr/bin/perl -e \'
      $| = 1;
      print "start of the systemcall<br>\n";
      $s = "teststr_";
      while (1) {
         print "len=".length($s)."<br>\n";
         sleep(1);
         $s .= $s;
      }
   \'';
   print htmlspecialchars($cmd);
?>
  </pre>
<?php
  ob_flush();
  flush();
  system($cmd);
?>
</body>
</html>


system_timeouttest.php
======================
<html>
<head>
  <title>php-systemcall-timeout test</title>
</head>
<body>
  php-systemcall-timeout test<br>
  ... and here's the system call:<br>
  <pre>
<?php
   $cmd = '/usr/bin/perl -e \'
      $| = 1;
      print "start of the systemcall<br>\n";
      $i = 0;
      while (1) {
         if (($i % 10000000) == 0) {
            print "i=".$i."<br>\n";
         }
         $i += 1;
      }
   \'';
   print htmlspecialchars($cmd);
?>
  </pre>
<?php
  ob_flush();
  flush();
  system($cmd);
?>
</body>
</html>




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to