Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
dra27 committed Nov 2, 2023
1 parent 25b4b13 commit e308701
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/core/opamStd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 () =
Expand Down
10 changes: 7 additions & 3 deletions src/stubs/win32/opamWindows.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit e308701

Please sign in to comment.