diff --git a/src/core/opamStd.ml b/src/core/opamStd.ml index ffbf788f9cf..c1cd919f8e4 100644 --- a/src/core/opamStd.ml +++ b/src/core/opamStd.ml @@ -1086,15 +1086,21 @@ module OpamSys = struct | "cmd.exe" -> Some (Accept SH_cmd) | "env.exe" -> Some (Accept SH_sh) | name -> + if not (Filename.check_suffix name ".exe") then + Printf.printf "Unexpected: %S\n%!" name; Option.map (fun shell -> Accept shell) (shell_of_string (Filename.chop_suffix name ".exe")) in lazy ( let lazy ancestors = windows_process_ancestry in + try match OpamList.filter_map categorize_process ancestors with | [] -> None | Accept most_relevant_shell :: _ -> Some most_relevant_shell + with e -> + Printf.eprintf "Trace:\n %s\n%!" (String.concat "\n " (List.map snd ancestors)); + raise e ) let guess_shell_compat () = diff --git a/src/stubs/win32/opamWindows.c b/src/stubs/win32/opamWindows.c index c4132f72102..d09285618ef 100644 --- a/src/stubs/win32/opamWindows.c +++ b/src/stubs/win32/opamWindows.c @@ -696,11 +696,15 @@ CAMLprim value OPAMW_GetProcessAncestry(value unit) hProcess = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, target); if (hProcess != NULL) { dwSize = MAX_PATH + 1; - if (!QueryFullProcessImageName(hProcess, 0, ExeName, &dwSize)) - ExeName[0] = L'\0'; + if (!QueryFullProcessImageName(hProcess, 0, ExeName, &dwSize)) { + ExeName[0] = L'a'; + ExeName[1] = L'\0'; + } CloseHandle(hProcess); } else { - ExeName[0] = L'\0'; + fprintf(stderr, "Mis-read: %ld, %ld, %lx\n", cur->LowPart, cur->HighPart, GetLastError()); fflush(stderr); + ExeName[0] = L'b'; + ExeName[1] = L'\0'; } info = caml_alloc_tuple(2); Store_field(info, 0, caml_copy_int32(target));