From: Bryan Tong Minh Date: Fri, 28 Aug 2009 19:32:07 +0000 (+0000) Subject: Fix wfShellBackgroundExec for windows. Works in maintenance/eval.php mode, have not... X-Git-Tag: 1.31.0-rc.0~40010 X-Git-Url: http://git.cyclocoop.org/ecrire?a=commitdiff_plain;h=363375c69e131fe2ddb12af25530445b472b6f00;p=lhc%2Fweb%2Fwiklou.git Fix wfShellBackgroundExec for windows. Works in maintenance/eval.php mode, have not tested when running php as webserver module. --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 7b98ed682d..e1eb6abd85 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2346,21 +2346,24 @@ function wfShellExec( $cmd, &$retval=null ) { } /** - * Executes a shell command in the background. Passes back the PID of the operation - * - * FIXME: Does not work on Windows; does not work at all (See CodeReview r55575) + * Executes a shell command in the background. Returns true of successful. * * @param $cmd String */ -function wfShellBackgroundExec( $cmd ){ +function wfShellBackgroundExec( $cmd ) { wfDebug( "wfShellBackgroundExec: $cmd\n" ); if ( ! wfShellExecEnabled() ) { - return "Unable to run external programs"; + return false; } - $pid = shell_exec( "nohup $cmd > /dev/null & echo $!" ); - return $pid; + if ( wfIsWindows() ) { + shell_exec( "start /b $cmd >nul"); + return true; + } else { + $pid = shell_exec( "nohup $cmd > /dev/null & echo $!" ); + return (bool)$pid; + } } /**