#33664 [NEW]: Console window appears when using exec()

From: Date: Tue, 12 Jul 2005 14:44:38 +0000
Subject: #33664 [NEW]: Console window appears when using exec()
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-81752@lists.php.net to get a copy of this message
From: richard dot quadling at bandvulc dot co dot uk Operating system: Windows PHP version: 5.0.4 PHP Bug Type: Feature/Change Request Bug description: Console window appears when using exec() Description: ------------ Hi. I have a LOT of php scripts which are launched via Windows task scheduler. They are executed using php-win.exe. Nothing wrong so far. Some of the scripts run other programs (e.g. WinRAR, NSLookup). When these programs are launched, a black window (the console window) appears. This is REALLY bad. This takes focus away from what I am doing. I'm using the php-win.exe which is supposed to NOT supply a console box. Now. Having looked at the source, I see that when an external application is called, it is invoked via the system command line interpreter. I've seen the various discussions about this and its security implications. Personally, I'd rather the command shell was NOT loaded, but ... The real issue for me is that the command shell is launched and creates a window. I suggest the following changes to the PHP source. /* $Id: tsrm_win32.c,v 1.26 2004/01/08 08:14:03 andi Exp $ */ Line 214 if (!CreateProcess(NULL, cmd, &security, &security, security.bInheritHandle, NORMAL_PRIORITY_CLASS, env, cwd, &startup, &process)) { becomes if (!CreateProcess(NULL, cmd, &security, &security, security.bInheritHandle, NORMAL_PRIORITY_CLASS | CREATE_NO_WINDOW, env, cwd, &startup, &process)) { /* $Id: proc_open.c,v 1.35 2005/07/01 06:49:29 hyanantha Exp $ */ Line 748 newprocok = CreateProcess(NULL, command_with_cmd, &security, &security, TRUE, NORMAL_PRIORITY_CLASS, env.envp, cwd, &si, &pi); becomes newprocok = CreateProcess(NULL, command_with_cmd, &security, &security, TRUE, NORMAL_PRIORITY_CLASS | CREATE_NO_WINDOW, env.envp, cwd, &si, &pi); static const char rcsid[] = "$Id: os_win32.c,v 1.6 2002/10/13 07:23:17 shane Exp $"; Line 1260 to 1269 success = CreateProcess(execPath, /* LPCSTR address of module name */ NULL, /* LPCSTR address of command line */ NULL, /* Process security attributes */ NULL, /* Thread security attributes */ TRUE, /* Inheritable Handes inherited. */ 0, /* DWORD creation flags */ env, /* Use parent environment block */ NULL, /* Address of current directory name */ &StartupInfo, /* Address of STARTUPINFO */ pInfo); /* Address of PROCESS_INFORMATION */ becomes success = CreateProcess(execPath, /* LPCSTR address of module name */ NULL, /* LPCSTR address of command line */ NULL, /* Process security attributes */ NULL, /* Thread security attributes */ TRUE, /* Inheritable Handes inherited. */ NORMAL_PRIORITY_CLASS | CREATE_NO_WINDOW, /* DWORD creation flags */ env, /* Use parent environment block */ NULL, /* Address of current directory name */ &StartupInfo, /* Address of STARTUPINFO */ pInfo); /* Address of PROCESS_INFORMATION */ Ideally, the CREATE_NO_WINDOW should only be added (or OR'd :-)) if the executable is not the normal php.exe (i.e. ISAPI, CGI, php-win.exe, etc). Regards, Richard Quadling. -- Edit bug report at http://bugs.php.net/?id=33664&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33664&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33664&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33664&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=33664&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=33664&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=33664&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=33664&r=needscript Try newer version: http://bugs.php.net/fix.php?id=33664&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=33664&r=support Expected behavior: http://bugs.php.net/fix.php?id=33664&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=33664&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=33664&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=33664&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33664&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=33664&r=dst IIS Stability: http://bugs.php.net/fix.php?id=33664&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=33664&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=33664&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=33664&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=33664&r=mysqlcfg

« previous php.bugs (#81752) next »