diff --git a/kitty/child.c b/kitty/child.c index 15e287e7d..7d9038c39 100644 --- a/kitty/child.c +++ b/kitty/child.c @@ -81,8 +81,9 @@ static PyObject* spawn(PyObject *self UNUSED, PyObject *args) { PyObject *argv_p, *env_p, *handled_signals_p; int master, slave, stdin_read_fd, stdin_write_fd, ready_read_fd, ready_write_fd; + const char *kitten_exe; char *cwd, *exe; - if (!PyArg_ParseTuple(args, "ssO!O!iiiiiiO!", &exe, &cwd, &PyTuple_Type, &argv_p, &PyTuple_Type, &env_p, &master, &slave, &stdin_read_fd, &stdin_write_fd, &ready_read_fd, &ready_write_fd, &PyTuple_Type, &handled_signals_p)) return NULL; + if (!PyArg_ParseTuple(args, "ssO!O!iiiiiiO!s", &exe, &cwd, &PyTuple_Type, &argv_p, &PyTuple_Type, &env_p, &master, &slave, &stdin_read_fd, &stdin_write_fd, &ready_read_fd, &ready_write_fd, &PyTuple_Type, &handled_signals_p, &kitten_exe)) return NULL; char name[2048] = {0}; if (ttyname_r(slave, name, sizeof(name) - 1) != 0) { PyErr_SetFromErrno(PyExc_OSError); return NULL; } char **argv = serialize_string_tuple(argv_p); @@ -151,14 +152,14 @@ spawn(PyObject *self UNUSED, PyObject *args) { environ = env; execvp(exe, argv); - // Report the failure and exec a shell instead, so that we are not left + // Report the failure and exec kitten instead, so that we are not left // with a forked but not exec'ed process write_to_stderr("Failed to launch child: "); write_to_stderr(exe); write_to_stderr("\nWith error: "); write_to_stderr(strerror(errno)); - write_to_stderr("\nPress Enter to exit.\n"); - execlp("sh", "sh", "-c", "read w", NULL); + write_to_stderr("\n"); + execlp(kitten_exe, "kitten", "__hold_till_enter__", NULL); exit(EXIT_FAILURE); break; } diff --git a/kitty/child.py b/kitty/child.py index e743be3e7..f7b18234e 100644 --- a/kitty/child.py +++ b/kitty/child.py @@ -9,7 +9,7 @@ from typing import TYPE_CHECKING, DefaultDict, Dict, Generator, List, Optional, import kitty.fast_data_types as fast_data_types -from .constants import handled_signals, is_freebsd, is_macos, kitty_base_dir, shell_path, terminfo_dir +from .constants import handled_signals, is_freebsd, is_macos, kitten_exe, kitty_base_dir, shell_path, terminfo_dir from .types import run_once from .utils import log_error, which @@ -320,7 +320,7 @@ class Child: else: pid = fast_data_types.spawn( self.final_exe, self.cwd, tuple(argv), env, master, slave, stdin_read_fd, stdin_write_fd, - ready_read_fd, ready_write_fd, tuple(handled_signals)) + ready_read_fd, ready_write_fd, tuple(handled_signals), kitten_exe()) os.close(slave) self.pid = pid self.child_fd = master diff --git a/kitty/fast_data_types.pyi b/kitty/fast_data_types.pyi index 5166df6b7..3f664ccfa 100644 --- a/kitty/fast_data_types.pyi +++ b/kitty/fast_data_types.pyi @@ -1313,6 +1313,7 @@ def spawn( ready_read_fd: int, ready_write_fd: int, handled_signals: Tuple[int, ...], + kitten_exe: str, ) -> int: pass