Skip to content

Commit 0125382

Browse files
mekwallCopilot
andauthored
Capture GetLastError() to facilitate diagnostics
Co-authored-by: Copilot <[email protected]>
1 parent c310634 commit 0125382

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/shared.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -704,11 +704,18 @@ int execute (
704704
SECURITY_ATTRIBUTES saAttr = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE};
705705

706706
// Create pipes for the child process's STDOUT and STDIN
707-
if (!CreatePipe(&hChildStdOutRd, &hChildStdOutWr, &saAttr, 0) ||
708-
!SetHandleInformation(hChildStdOutRd, HANDLE_FLAG_INHERIT, 0) ||
709-
!CreatePipe(&hChildStdInRd, &hChildStdInWr, &saAttr, 0) ||
710-
!SetHandleInformation(hChildStdInWr, HANDLE_FLAG_INHERIT, 0))
711-
return -1;
707+
if (!CreatePipe(&hChildStdOutRd, &hChildStdOutWr, &saAttr, 0)) {
708+
return -1 * static_cast<int>(GetLastError());
709+
}
710+
if (!SetHandleInformation(hChildStdOutRd, HANDLE_FLAG_INHERIT, 0)) {
711+
return -1 * static_cast<int>(GetLastError());
712+
}
713+
if (!CreatePipe(&hChildStdInRd, &hChildStdInWr, &saAttr, 0)) {
714+
return -1 * static_cast<int>(GetLastError());
715+
}
716+
if (!SetHandleInformation(hChildStdInWr, HANDLE_FLAG_INHERIT, 0)) {
717+
return -1 * static_cast<int>(GetLastError());
718+
}
712719

713720
// Prepare the child process
714721
PROCESS_INFORMATION piProcInfo = {0};

0 commit comments

Comments
 (0)