1.1 --- a/common/src/fixpath.c Wed Jan 02 15:36:00 2013 +0100 1.2 +++ b/common/src/fixpath.c Thu Jan 03 20:54:38 2013 +0100 1.3 @@ -29,6 +29,29 @@ 1.4 #include <string.h> 1.5 #include <malloc.h> 1.6 1.7 +void report_error() 1.8 +{ 1.9 + LPVOID lpMsgBuf; 1.10 + DWORD dw = GetLastError(); 1.11 + 1.12 + FormatMessage( 1.13 + FORMAT_MESSAGE_ALLOCATE_BUFFER | 1.14 + FORMAT_MESSAGE_FROM_SYSTEM | 1.15 + FORMAT_MESSAGE_IGNORE_INSERTS, 1.16 + NULL, 1.17 + dw, 1.18 + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 1.19 + (LPTSTR) &lpMsgBuf, 1.20 + 0, 1.21 + NULL); 1.22 + 1.23 + fprintf(stderr, 1.24 + "Could not start process! Failed with error %d: %s\n", 1.25 + dw, lpMsgBuf); 1.26 + 1.27 + LocalFree(lpMsgBuf); 1.28 +} 1.29 + 1.30 /* 1.31 * Test if pos points to /cygdrive/_/ where _ can 1.32 * be any character. 1.33 @@ -256,7 +279,7 @@ 1.34 DWORD exitCode; 1.35 1.36 if (argc<3 || argv[1][0] != '-' || (argv[1][1] != 'c' && argv[1][1] != 'm')) { 1.37 - fprintf(stderr, "Usage: fixpath -c|m<path@path@...> /cygdrive/c/WINDOWS/notepad.exe /cygdrive/c/x/test.txt"); 1.38 + fprintf(stderr, "Usage: fixpath -c|m<path@path@...> /cygdrive/c/WINDOWS/notepad.exe /cygdrive/c/x/test.txt\n"); 1.39 exit(0); 1.40 } 1.41 1.42 @@ -308,11 +331,10 @@ 1.43 0, 1.44 &si, 1.45 &pi); 1.46 - if(!rc) 1.47 - { 1.48 - //Could not start process; 1.49 - fprintf(stderr, "Could not start process!\n"); 1.50 - exit(-1); 1.51 + if(!rc) { 1.52 + // Could not start process for some reason. Try to report why: 1.53 + report_error(); 1.54 + exit(rc); 1.55 } 1.56 1.57 WaitForSingleObject(pi.hProcess,INFINITE);