php5.3 exec() : output truncate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I want to get the list of running processes. also, I call exec() with "ps -A"
(ps -A displays almost all processes of all users)
Unfortunatly, the output of "ps -A" seems incomplete

the test file test.php:
<?php
unset($buf);
unset($res);
exec("ps -A", $buf, $res);
for($i=0; $i < count($buf); $i++)
{
    echo($buf[$i]."<br>");
}
?>

If I run the test.php under the context of httpd (from http://<server>/test.php), I can see only a subset of running processes (some processes of user "apache")

PID TTY TIME CMD
3207 ? 00:00:00 httpd
3359 ? 00:00:00 httpd
3360 ? 00:00:00 httpd
3361 ? 00:00:00 httpd
3362 ? 00:00:00 httpd
3363 ? 00:00:00 httpd
3364 ? 00:00:00 httpd
3365 ? 00:00:00 httpd
3366 ? 00:00:00 httpd
3569 ? 00:00:00 ps

If I run the same script directly from php (from user apache) , I can see *all* processes as expected

# sudo -u apache php -f test.php
  PID TTY          TIME CMD<br>
    1 ?        00:00:01 init<br>
    2 ?        00:00:00 migration/0<br>
    3 ?        00:00:00 ksoftirqd/0<br>
    4 ?        00:00:00 watchdog/0<br>
    5 ?        00:00:00 events/0<br>
    6 ?        00:00:00 khelper<br>
[...]

Is it a problem with exec() or with "ps -A" or with .... ?

any ideas ?


more information :
OS = centos 5.5
# httpd -v
Server version: Apache/2.2.3
Server built:   Jan 10 2013 08:22:14
# php -v
PHP 5.3.3 (cli) (built: Jun 27 2012 12:25:37)


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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux