Fix unhandled exceptions not being printed to stderr on macOS when run from launch services and using prewarming

This commit is contained in:
Kovid Goyal 2022-08-16 15:27:41 +05:30
parent 48a9584688
commit 56f45e8b0f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 12 additions and 1 deletions

View File

@ -1483,3 +1483,6 @@ class SingleKey:
def __iter__(self) -> Iterator[int]: ...
def _replace(self, mods: int = 0, is_native: object = False, key: int = -1) -> 'SingleKey': ...
def resolve_kitty_mod(self, mod: int) -> 'SingleKey': ...
def set_use_os_log(yes: bool) -> None: ...

View File

@ -59,8 +59,15 @@ log_error_string(PyObject *self UNUSED, PyObject *args) {
Py_RETURN_NONE;
}
static PyObject*
set_use_os_log(PyObject *self UNUSED, PyObject *args) {
use_os_log = PyObject_IsTrue(args) ? true : false;
Py_RETURN_NONE;
}
static PyMethodDef module_methods[] = {
METHODB(log_error_string, METH_VARARGS),
METHODB(set_use_os_log, METH_O),
{NULL, NULL, 0, NULL} /* Sentinel */
};

View File

@ -29,7 +29,7 @@ from kitty.entry_points import main as main_entry_point
from kitty.fast_data_types import (
CLD_EXITED, CLD_KILLED, CLD_STOPPED, get_options, getpeereid,
install_signal_handlers, read_signals, remove_signal_handlers, safe_pipe,
set_options
set_options, set_use_os_log
)
from kitty.options.types import Options
from kitty.shm import SharedMemory
@ -869,6 +869,7 @@ def fork_prewarm_process(opts: Options, use_exec: bool = False) -> Optional[Prew
p.reload_kitty_config()
return p
# child
set_use_os_log(False)
safe_close(stdin_write)
safe_close(stdout_read)
safe_close(death_notify_read)