Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can i find CreateProcess error codes' details?

I'm running in php the following:

$res = proc_open($cmd, $descriptorspec, $pipes, "C:\\xampp\htdocs\\",null,array('bypass_shell'=>true));

Problem is that it gives the following error:

Warning: proc_open(): CreateProcess failed, error code - 3

Where can I find out what the error means?

PS: it's on a Windows Server 2007. SP2. User is admin, full acess. PHP is version 5.3.1

like image 814
Tjorriemorrie Avatar asked Feb 14 '11 09:02

Tjorriemorrie


1 Answers

In Windows, CreateProcess doesn't actually return an error code. Instead you use GetLastError to find more details if CreateProcess fails, then use FormatMessage to turn the error code from GetLastError into a proper description. (The error codes from GetLastError can also be decoded using this list)

Looking at the source for proc_open(), PHP is actually doing the GetLastError() for you in the event of a failure, and the error code it's logging is the return from GetLastError() rather than from CreateProcess (which returns a BOOL, unlikely to be 3 :) )

Note that proc_open uses this to dump the message:

php_error_docref(NULL TSRMLS_CC, E_WARNING, "CreateProcess failed, error code - %u", dw);

...so that "-" you've got before the 3 is just a hyphen, not a minus sign. You're therefore getting error code 3, which, according to that list means "The system cannot find the path specified.".

like image 181
Matt Gibson Avatar answered Sep 20 '22 02:09

Matt Gibson