gwynne Tue Jul 3 02:32:14 2007 UTC
Modified files:
/livedocs build.php
Log:
Execution of shell commands now shows output in realtime in both stdout and
build log; run with BUILD_PHP_DEBUG=yes for output to stdout (warning: very
noisy)
http://cvs.php.net/viewvc.cgi/livedocs/build.php?r1=1.4&r2=1.5&diff_format=u
Index: livedocs/build.php
diff -u livedocs/build.php:1.4 livedocs/build.php:1.5
--- livedocs/build.php:1.4 Tue Jul 3 01:23:05 2007
+++ livedocs/build.php Tue Jul 3 02:32:14 2007
@@ -57,11 +57,24 @@
}
*/
-function sneaky_shell_exec( $command ) {
- exec( $command, $output, $result );
- foreach ( $output as $line )
- buildmsg( trim( substr( $line, strrpos( $line, "\r" ) ) ) );
- return $result;
+function sneaky_shell_exec( $command, $output_target = NULL ) {
+ $desc = array(
+ 0 => array( 'file', '/dev/null', 'r' ),
+ 1 => ( $output_target === NULL ? array( 'pipe', 'w' ) : array(
'file', $output_target, 'w' ) ),
+ 2 => array( 'file', '/dev/null', 'w' )
+ );
+
+ $status = -1;
+ $handle = proc_open( $command, $desc, $pipes );
+ if ( is_resource( $handle ) ) {
+ if ( isset( $pipes[ 1 ] ) && is_resource( $pipes[ 1 ] ) ) {
+ while ( ( $s = fgets( $pipes[ 1 ] ) ) !== FALSE )
+ buildmsg( substr( $s, 0, -1 ) );
+ fclose( $pipes[ 1 ] );
+ }
+ $status = proc_close( $handle );
+ }
+ return $status;
}
function parse_options() {
@@ -116,7 +129,7 @@
// For debugging:
// sneaky_shell_exec( "xmllint --format
\"{$GENDIR}/toc-ugly.xml\" > {$GENDIR}/toc.xml" );
- sneaky_shell_exec( "{$PHP} -f \"{$LIVEDOCS}/mktoc.php\"
\"{$GENDIR}/toc-ugly.xml\" > \"{$GENDIR}/toc-insert.sql\"" );
+ sneaky_shell_exec( "{$PHP} -f \"{$LIVEDOCS}/mktoc.php\"
\"{$GENDIR}/toc-ugly.xml\"", "{$GENDIR}/toc-insert.sql" );
}
buildmsg( "Making index for {$i}: " . date( DATE_RFC2822 ) );