PHP shell_exec() always gives error "Broken pipe" when using pipe
Hi all.
I have an error im my apache's error.log saying: Code:
/bin/grep: writing output: Broken pipe Code:
shell_exec("/bin/netstat -e -p --tcp -n 2> /dev/null | /bin/grep -v root | /bin/grep -v 127.0.0.1 | /bin/grep -cE '.*(python|transmissionc|wget|nzbperl|java).*'"); I replaced (just for test) the upper line with: Code:
shell_exec("ls | ls | ls | ls"); Code:
ls: write error: Broken pipe I've tried with su -c "ls | ls | ls | ls" www-data and also with su - www-data followed with ls | ls | ls | ls without errors. I also get the same error if I make a test.php file containing just: Code:
<? Code:
# php -f test.php 2>&1 Can you please just shoot out any idea that first gets to your mind of what the problem could actually be? I have torrentflux-b4rt installed on my debian machine (stable, squeeze 6.0.3, "Linux ninja 2.6.26-2-amd64 #1 SMP Wed Sep 21 03:36:44 UTC 2011 x86_64 GNU/Linux") with apache web server (apache2 2.2.16-6+squeeze4) and php5 (libapache2-mod-php5 5.3.3-7+squeeze3) installed. I'm not sure if I've chosen the correct forum, but I hope mods will point this out to me if I'm wrong. |
I've solved this issue. It had to do something with ulimit command.
Even though I had uncommented line "session required pam_limits.so" in /etc/pam.d/login and I had put Code:
* hard nofile 102400 it still didn't want to create more than 20 apache processes (required by torrentflux) I've restarted apache2 numerous times and finally I managed to solve this by adding: Code:
root soft nproc 102400 and also changing apache config file /etc/apache2/apache2.conf by modifying this section: Code:
<IfModule mpm_prefork_module> After the restart of apache with /etc/init.d/apache2 restart, everything worked great (so far) :) Hope this helps someone in the future :) |
All times are GMT -5. The time now is 08:16 PM. |