[SOLVED] Re: [PHP] php5.3 exec() : output truncate
| From: | patrick ficheux | Date: | Thu, 31 Jan 2013 06:57:21 +0000 |
| Subject: | [SOLVED] Re: [PHP] php5.3 exec() : output truncate | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-320128@lists.php.net to get a copy of this message | ||
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.phpPID 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)