gardesk/garterm / 7f86e4a

Browse files

write execvp error to PTY instead of silently discarding

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
7f86e4a0488f1383e5d23d598645f2ae42848fd6
Parents
94f8f47
Tree
27e5800

1 changed file

StatusFile+-
M garterm/src/pty/unix.rs 10 1
garterm/src/pty/unix.rsmodified
@@ -105,7 +105,16 @@ impl Pty {
105105
                     .unwrap_or_else(|| shell.to_string());
106106
                 let argv0 = CString::new(shell_name).unwrap();
107107
 
108
-                execvp(&shell_cstr, &[argv0]).ok();
108
+                // execvp only returns on error (Ok is Infallible)
109
+                let e = execvp(&shell_cstr, &[argv0]).unwrap_err();
110
+                let msg = format!("garterm: failed to exec '{}': {}\r\n", shell, e);
111
+                let _ = unsafe {
112
+                    libc::write(
113
+                        libc::STDERR_FILENO,
114
+                        msg.as_ptr() as *const _,
115
+                        msg.len(),
116
+                    )
117
+                };
109118
 
110119
                 // If exec fails, use _exit to avoid running atexit handlers
111120
                 // (which can crash in GPU drivers like NVIDIA after fork)