--- function.original.c Tue Nov 30 20:51:24 2004 +++ function.changed.c Wed Feb 16 19:10:44 2005 @@ -1298,7 +1298,7 @@ SECURITY_ATTRIBUTES saAttr; HANDLE hIn; HANDLE hErr; - HANDLE hChildOutRd; + HANDLE hChildOutRd, hChildOutTmp; HANDLE hChildOutWr; HANDLE hProcess; @@ -1329,8 +1329,19 @@ GetLastError()); } - if (!CreatePipe(&hChildOutRd, &hChildOutWr, &saAttr, 0)) + if (!CreatePipe(&hChildOutTmp, &hChildOutWr, &saAttr, 0)) fatal (NILF, _("CreatePipe() failed (e=%d)\n"), GetLastError()); + if (DuplicateHandle(GetCurrentProcess(), + hChildOutTmp, + GetCurrentProcess(), + &hChildOutRd, + 0, + FALSE, // this one not inherited + DUPLICATE_SAME_ACCESS) == FALSE) { + fatal (NILF, _("create_child_process: DuplicateHandle(Tmp) failed (e=%d)\n"), + GetLastError()); + } + CloseHandle(hChildOutTmp); hProcess = process_init_fd(hIn, hChildOutWr, hErr); --- w32\subproc\sub_proc.original.c Mon Feb 23 07:25:54 2004 +++ w32\subproc\sub_proc.changed.c Mon Jan 17 12:05:14 2005 @@ -383,6 +383,7 @@ sub_process *pproc = (sub_process *)proc; char *shell_name = 0; int file_not_found=0; + int is_executable= 0; HANDLE exec_handle; char buf[256]; DWORD bytes_returned; @@ -456,6 +457,10 @@ } } + else if (buf[0] == 'M' && buf[1] == 'Z') { + /* Mark Zbikowski's old-exec stub */ + is_executable = 1; + } CloseHandle(exec_handle); } @@ -463,9 +468,28 @@ if (file_not_found) command_line = make_command_line( shell_name, exec_path, argv); - else + else if (shell_name || is_executable) command_line = make_command_line( shell_name, file_info.szPathName, argv); + else { /* build command line with possibly quoted file name + * (this may alter the %0% argument of a batch file) */ + if (argv && argv[0] && argv[1]) { + char *save_arg_0 = argv[0]; + argv[0] = file_info.szPathName; + command_line = make_command_line( NULL, NULL, argv); + argv[0] = save_arg_0; + } + else + { + char *my_argv[2]; + my_argv[0] = file_info.szPathName; + my_argv[1] = NULL; + command_line = make_command_line( NULL, NULL, my_argv); + } + + file_not_found = 1; + flags |= CREATE_NEW_PROCESS_GROUP; + } if ( command_line == NULL ) { pproc->last_err = 0; @@ -513,7 +537,8 @@ command_line, NULL, 0, /* default security attributes for thread */ - TRUE, /* inherit handles (e.g. helper pipes, oserv socket) */ + is_executable, /* executables inherit handles (e.g. helper pipes, oserv socket) + * shell are assumed to set up pipes themselves */ flags, envblk, 0, /* default starting directory */