[PHP] php5.3 exec() : output truncate
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 CMDbr 1 ?00:00:01 initbr 2 ?00:00:00 migration/0br 3 ?00:00:00 ksoftirqd/0br 4 ?00:00:00 watchdog/0br 5 ?00:00:00 events/0br 6 ?00:00:00 khelperbr [...] 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
Re: [PHP] php5.3 exec() : output truncate
On 01/30/2013 10:14 AM, patrick ficheux wrote: Hi, I want to get the list of running processes. also, I call exec() with ps -A What user is your httpd process running as? run this from your cli: ps aux | grep httpd and show us the output -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] [SOLVED] Re: [PHP] php5.3 exec() : output truncate
I found the reason of this issue : SELinux by defaut, SELinux is enabled on CentOS5.5 = httpd runs with restricted rights If I temporary disabled SELinux + restart httpd = ps -A from my script runs as expected $ setenforce 0 $ /etc/init.d/httpd restart Le 30/01/2013 19:14, patrick ficheux a écrit : 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 CMDbr 1 ?00:00:01 initbr 2 ?00:00:00 migration/0br 3 ?00:00:00 ksoftirqd/0br 4 ?00:00:00 watchdog/0br 5 ?00:00:00 events/0br 6 ?00:00:00 khelperbr [...] 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