Re: [PHP-DEV] exec in CLI vs. mod_php

2003-05-31 Thread Zeev Suraski
At 18:18 30/05/2003, Wez Furlong wrote: For exec() and system(), we don't send any input and only capture stdout. So, everything except the stdout fileno can be closed-on-exec. The user can do the usual 2>&1 trick to get the stderr output as we run their command using the shell. Unless I'm missing

Re: [PHP-DEV] exec in CLI vs. mod_php

2003-05-31 Thread Wez Furlong
For exec() and system(), we don't send any input and only capture stdout. So, everything except the stdout fileno can be closed-on-exec. The user can do the usual 2>&1 trick to get the stderr output as we run their command using the shell. --Wez. On Fri, 30 May 2003, Zeev Suraski wrote: > At 18

Re: [PHP-DEV] exec in CLI vs. mod_php

2003-05-31 Thread Zeev Suraski
At 18:02 30/05/2003, Wez Furlong wrote: I *think* that in the case of Brian's question (which applies to the exec(), system() and so on family of PHP functions), we can safely loop throught the descriptors (except for those we will be using to capture or pass-thru the output) and set the close-on-e

Re: [PHP-DEV] exec in CLI vs. mod_php

2003-05-31 Thread Wez Furlong
I *think* that in the case of Brian's question (which applies to the exec(), system() and so on family of PHP functions), we can safely loop throught the descriptors (except for those we will be using to capture or pass-thru the output) and set the close-on-exec flag prior to forking. I don't have

Re: [PHP-DEV] exec in CLI vs. mod_php

2003-05-31 Thread Brian Moon
IL PROTECTED]> To: "Wez Furlong" <[EMAIL PROTECTED]> Cc: "Brian Moon" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Friday, May 30, 2003 9:54 AM Subject: Re: [PHP-DEV] exec in CLI vs. mod_php | At 17:44 30/05/2003, Wez Furlong wrote: | >I think I did

Re: [PHP-DEV] exec in CLI vs. mod_php

2003-05-31 Thread Zeev Suraski
At 17:44 30/05/2003, Wez Furlong wrote: I think I did check, but there were no useful comments. if close()ing them before exec'ing is a problem, can't we just set the close-on-exec flag on the fd's ? This will cause the descriptors to be dup'd for the fork, and the duplicates to be closed when the

Re: [PHP-DEV] exec in CLI vs. mod_php

2003-05-31 Thread Wez Furlong
I think I did check, but there were no useful comments. if close()ing them before exec'ing is a problem, can't we just set the close-on-exec flag on the fd's ? This will cause the descriptors to be dup'd for the fork, and the duplicates to be closed when the child execs; in theory, that will leave

Re: [PHP-DEV] exec in CLI vs. mod_php

2003-05-31 Thread Zeev Suraski
At 22:44 29/05/2003, Wez Furlong wrote: Under apache, you inherit all of the apache sockets when the libc forks and execs your script. This causes some problems (there are one or two bug reports about this in the bug db) with processes waiting around on the sockets. It looks like there was some cod

Re: [PHP-DEV] exec in CLI vs. mod_php

2003-05-31 Thread Jani Taskinen
On Thu, 29 May 2003, Wez Furlong wrote: >It looks like there was some code in the apache SAPI to avoid this >problem, but it is currently commented out with an explanation that it >is "problematic". What code exactly..? Maybe ask that who commented out why it was problematic? --Jani

Re: [PHP-DEV] exec in CLI vs. mod_php

2003-05-30 Thread Wez Furlong
Under apache, you inherit all of the apache sockets when the libc forks and execs your script. This causes some problems (there are one or two bug reports about this in the bug db) with processes waiting around on the sockets. It looks like there was some code in the apache SAPI to avoid this pro

[PHP-DEV] exec in CLI vs. mod_php

2003-05-30 Thread Brian Moon
I am trying to figure out what is internally different about exec between CLI and mod_php. If exec() a script from CLI and said script forks, I get my prompt right back. test.php fork.php #!/usr/local/bin/php 0) { exit(); } touch("/tmp/file.txt"); sleep(5); ?>