On Thu, Mar 29, 2007 at 09:06:20PM +0100, Stephane Chazelas wrote: [...] > print STDOUT "..."; > actually did a write(16, "..."), so STDOUT was affected another > fd that 1. Tomorrow, I'll try doing a system() within perl, but > I suspect for instance system("echo foo") will no output > anything to the socket. [...]
I can confirm. This script: print "Content-Type: text/plain\r\n\r\n"; print "test\n"; system 'lsof -p $$'; print "test\n"; outputs test test while print "Content-Type: text/plain\r\n\r\n"; print "test\n"; system 'lsof -p $$ >&16'; print "test\n"; outputs COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME [...] sh 19113 www-data 0r CHR 1,3 1673 /dev/null sh 19113 www-data 1w CHR 1,3 1673 /dev/null sh 19113 www-data 2w REG 8,9 2041426 244362 /var/log/apache2/error.log [...] sh 19113 www-data 16u IPv4 14009527 TCP ant.artesyncp.com:www->ant.artesyncp.com:43127 (ESTABLISHED) fds 0 and 1 are /dev/null as they should be if apache was not running modperl because modperl does dup(0); close(0); dup(1); close(1); so that the second dup assigns stdin as a copy of stdout! Cheers, Stephane