Skip to content

Commit 10b4410

Browse files
authored
Merge pull request #9 from why0why0why/main
feat: return child process exit code in main function
2 parents 76b44ae + fc19415 commit 10b4410

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

main.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static void __cdecl InputHandlerThread(LPVOID);
4848

4949
int main(int argc, const char* argv[]) {
5050
Context ctx;
51+
uint32_t childExitCode = 0;
5152

5253
ParseArgs(argc, argv, &ctx);
5354

@@ -87,6 +88,8 @@ int main(int argc, const char* argv[]) {
8788

8889
WaitForMultipleObjects(sizeof(ctx.events) / sizeof(HANDLE), ctx.events, FALSE,
8990
INFINITE);
91+
92+
GetExitCodeProcess(cmdProc.hProcess, &childExitCode);
9093
}
9194

9295
CloseHandle(cmdProc.hThread);
@@ -107,7 +110,7 @@ int main(int argc, const char* argv[]) {
107110

108111
CloseHandle(ctx.events[0]);
109112
}
110-
return S_OK == hr ? EXIT_SUCCESS : EXIT_FAILURE;
113+
return S_OK == hr ? childExitCode : EXIT_FAILURE;
111114
}
112115

113116
static void ParseArgs(int argc, const char* argv[], Context* ctx) {

0 commit comments

Comments
 (0)