diff --git a/kitty/child.py b/kitty/child.py index 7f4e998ad..a2edabb93 100644 --- a/kitty/child.py +++ b/kitty/child.py @@ -252,7 +252,7 @@ class Child: env['KITTY_PID'] = getpid() if not self.is_prewarmed: env['KITTY_PREWARM_SOCKET'] = fast_data_types.get_boss().prewarm.socket_env_var() - env['KITTY_PREWARM_SOCKET_REAL_TTY'] = '0' * 32 + env['KITTY_PREWARM_SOCKET_REAL_TTY'] = ' ' * 32 if self.cwd: # needed in case cwd is a symlink, in which case shells # can use it to display the current directory name rather diff --git a/kitty_tests/prewarm.py b/kitty_tests/prewarm.py index 45c0442d1..108562aa4 100644 --- a/kitty_tests/prewarm.py +++ b/kitty_tests/prewarm.py @@ -68,7 +68,7 @@ def socket_child_main(exit_code=0, initial_print=''): env.update({ 'TEST_ENV_PASS': 'xyz', 'KITTY_PREWARM_SOCKET': p.socket_env_var(), - 'KITTY_PREWARM_SOCKET_REAL_TTY': '0' * 32, + 'KITTY_PREWARM_SOCKET_REAL_TTY': ' ' * 32, 'TERM': 'xterm-kitty', 'TERMINFO': terminfo_dir }) diff --git a/prewarm-launcher.c b/prewarm-launcher.c index bc822e228..f6304894b 100644 --- a/prewarm-launcher.c +++ b/prewarm-launcher.c @@ -44,6 +44,9 @@ #define MAX(x, y) __extension__ ({ \ __typeof__ (x) a = (x); __typeof__ (y) b = (y); \ a > b ? a : b;}) +#define MIN(x, y) __extension__ ({ \ + __typeof__ (x) a = (x); __typeof__ (y) b = (y); \ + a < b ? a : b;}) // }}} #define IO_BUZ_SZ 8192 @@ -700,7 +703,8 @@ use_prewarmed_process(int argc, char *argv[], char *envp[]) { while (*envp) { if (strncmp(*envp, "KITTY_PREWARM_SOCKET_REAL_TTY=", 2) == 0) { - sprintf(*envp, "KITTY_PREWARM_SOCKET_REAL_TTY=%s", child_tty_name); + char *p = *envp + sizeof("KITTY_PREWARM_SOCKET_REAL_TTY=") - 1; + snprintf(p, strlen(p) + 1, "%s", child_tty_name); } envp++; }