]> prime8.dev >> repos - ttyd.git/commitdiff
pty: print process exit code on error
authorShuanglei Tao <tsl0922@gmail.com>
Fri, 13 Jan 2023 00:40:52 +0000 (08:40 +0800)
committerShuanglei Tao <tsl0922@gmail.com>
Fri, 13 Jan 2023 00:40:52 +0000 (08:40 +0800)
src/pty.c

index 759410a45a6785b7cebe6569ac80685fa1a0e156..bbe8e22be6f429137cc27b8ed67dd7713c6fe0ae 100644 (file)
--- a/src/pty.c
+++ b/src/pty.c
@@ -354,6 +354,8 @@ int pty_spawn(pty_process *process, pty_read_cb read_cb, pty_exit_cb exit_cb) {
 
   if (!CreateProcessW(NULL, cmdline, NULL, NULL, FALSE, flags, NULL, cwd, &process->si.StartupInfo, &pi)) {
     print_error("CreateProcessW");
+    DWORD exitCode = 0;
+    if (GetExitCodeProcess(pi.hProcess, &exitCode)) printf("== exit code: %d\n", exitCode);
     goto cleanup;
   }