From 363375c69e131fe2ddb12af25530445b472b6f00 Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh Date: Fri, 28 Aug 2009 19:32:07 +0000 Subject: [PATCH] Fix wfShellBackgroundExec for windows. Works in maintenance/eval.php mode, have not tested when running php as webserver module. --- includes/GlobalFunctions.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) 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; + } } /** -- 2.20.1