diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2011-03-01 14:35:34 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2011-03-01 14:35:34 +0000 |
commit | d14a599c4c5df86c60ebb1ac9000416c1177f4cd (patch) | |
tree | 8c9fe97251b24afb4662edeb51bc76c97d552ef6 /Build/source/texk/kpathsea/mingw32.c | |
parent | 573fe9ca631fee2865f58133c28c7522d80d721b (diff) |
Remove win32_system() for __MINGW__
originally introduced to work around bugs in system() from Win9x
git-svn-id: svn://tug.org/texlive/trunk@21567 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/kpathsea/mingw32.c')
-rw-r--r-- | Build/source/texk/kpathsea/mingw32.c | 149 |
1 files changed, 0 insertions, 149 deletions
diff --git a/Build/source/texk/kpathsea/mingw32.c b/Build/source/texk/kpathsea/mingw32.c index d2c5838e510..01d3eda5e1f 100644 --- a/Build/source/texk/kpathsea/mingw32.c +++ b/Build/source/texk/kpathsea/mingw32.c @@ -859,153 +859,4 @@ build_cmdline(char ***cmd, char *input, char *output) return line; } -/* - It has been proven that system() fails to retrieve exit codes - under Win9x. This is a workaround for this bug. -*/ - -int -win32_system(const char *cmd, int async) -{ - STARTUPINFO si; - PROCESS_INFORMATION pi; - DWORD ret = 0; - HANDLE hIn, hOut; - SECURITY_ATTRIBUTES sa = { sizeof(SECURITY_ATTRIBUTES), NULL, TRUE }; - int i; - - char *app_name, *new_cmd; - char *red_input, *red_output, ***cmd_pipe; - - /* Reset errno ??? */ - errno = 0; - hIn = INVALID_HANDLE_VALUE; /* compiler warning */ - hOut = INVALID_HANDLE_VALUE; /* compiler warning */ - - /* Admittedly, the command interpreter will allways be found. */ - if (! cmd) { - errno = 0; -#ifdef _TRACE - fprintf(stderr, "system: (null) command.\n"); -#endif - return 1; - } - - if (look_for_cmd(cmd, &app_name) == FALSE) { - /* Failed to find the command or malformed cmd */ - errno = ENOEXEC; -#ifdef _TRACE - fprintf(stderr, "system: failed to find command.\n"); -#endif - return -1; - } - - new_cmd = xstrdup(cmd); - cmd_pipe = parse_cmdline(new_cmd, &red_input, &red_output); - - for (i = 0; cmd_pipe[i]; i++) { - - /* free the cmd and build the current one */ - if (new_cmd) free(new_cmd); - - new_cmd = build_cmdline(&cmd_pipe[i], NULL, NULL); - - /* First time, use red_input if available */ - if (i == 0) { - if (red_input) { - hIn = CreateFile(red_input, - GENERIC_READ, - FILE_SHARE_READ | FILE_SHARE_WRITE, - &sa, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - if (hIn == INVALID_HANDLE_VALUE) { -#ifdef _TRACE - fprintf(stderr, "system: failed to open hIn (%s) with error %d.\n", red_input, GetLastError()); -#endif - errno = EIO; - return -1; - } - } - else { - hIn = GetStdHandle(STD_INPUT_HANDLE); - } - } - /* Last time, use red_output if available */ - if (cmd_pipe[i+1] == NULL) { - if (red_output) { - hOut = CreateFile(red_output, - GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - &sa, - OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - if (hOut == INVALID_HANDLE_VALUE) { -#ifdef _TRACE - fprintf(stderr, "system: failed to open hOut (%s) with error %d.\n", red_output, GetLastError()); -#endif - errno = EIO; - return -1; - } - } - else { - hOut = GetStdHandle(STD_OUTPUT_HANDLE); - } - } - - ZeroMemory( &si, sizeof(STARTUPINFO) ); - si.cb = sizeof(STARTUPINFO); - si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; - si.wShowWindow = SW_SHOW; - si.hStdInput = hIn; - si.hStdOutput = hOut; - si.hStdError = GetStdHandle(STD_ERROR_HANDLE); - -#ifdef _TRACE - fprintf(stderr, "Executing: %s\n", new_cmd); -#endif - if (CreateProcess(app_name, - new_cmd, - NULL, - NULL, - TRUE, - 0, - NULL, - NULL, - &si, - &pi) == 0) { - fprintf(stderr, "win32_system(%s) call failed (Error %d).\n", cmd, (int)GetLastError()); - return -1; - } - - /* Only the process handle is needed */ - CloseHandle(pi.hThread); - - if (async == 0) { - if (WaitForSingleObject(pi.hProcess, INFINITE) == WAIT_OBJECT_0) { - if (GetExitCodeProcess(pi.hProcess, &ret) == 0) { - fprintf(stderr, "Failed to retrieve exit code: %s (Error %d)\n", cmd, (int)GetLastError()); - ret = -1; - } - } - else { - fprintf(stderr, "Failed to wait for process termination: %s (Error %d)\n", cmd, (int)GetLastError()); - ret = -1; - } - } - - CloseHandle(pi.hProcess); - - if (red_input) CloseHandle(hIn); - if (red_output) CloseHandle(hOut); - } - - if (new_cmd) free(new_cmd); - if (app_name) free(app_name); - - return ret; -} - #endif /* __MINGW32__ */ |