prewarm wrapper should indicate it is active via the process environment
This commit is contained in:
parent
67cb466ea9
commit
f7a7e39a36
@ -115,6 +115,14 @@ def socket_child_main(exit_code=0, initial_print=''):
|
||||
pty.wait_till(lambda: f'Screen size changed: {cols + 3}' in pty.screen_contents())
|
||||
os.close(pty.master_fd)
|
||||
|
||||
with self.subTest(msg='test env rewrite'):
|
||||
pty = self.create_pty(
|
||||
argv=[kitty_exe(), '+runpy', src + 'socket_child_main(initial_print="child ready:")'], cols=cols, env=env, cwd=cwd)
|
||||
pty.wait_till(lambda: 'child ready:' in pty.screen_contents())
|
||||
from kitty.child import environ_of_process
|
||||
self.assertTrue(environ_of_process(pty.child_pid).get('KITTY_PWPR'))
|
||||
os.close(pty.master_fd)
|
||||
|
||||
with self.subTest(msg='test passing of data via cwd, env vars and stdin/stdout redirection'):
|
||||
stdin_r, stdin_w = os.pipe()
|
||||
os.set_inheritable(stdin_w, False)
|
||||
|
||||
@ -268,11 +268,11 @@ read_exe_path(char *exe, size_t buf_sz) {
|
||||
}
|
||||
#endif // }}}
|
||||
|
||||
extern void use_prewarmed_process(int argc, char *argv[]);
|
||||
extern void use_prewarmed_process(int argc, char *argv[], char *envp[]);
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int main(int argc, char *argv[], char* envp[]) {
|
||||
if (argc < 1 || !argv) { fprintf(stderr, "Invalid argc/argv\n"); return 1; }
|
||||
use_prewarmed_process(argc, argv);
|
||||
use_prewarmed_process(argc, argv, envp);
|
||||
char exe[PATH_MAX+1] = {0};
|
||||
char exe_dir_buf[PATH_MAX+1] = {0};
|
||||
FREE_AFTER_FUNCTION const char *lc_ctype = NULL;
|
||||
|
||||
@ -673,7 +673,7 @@ check_socket_addr(char *addr) {
|
||||
}
|
||||
|
||||
void
|
||||
use_prewarmed_process(int argc, char *argv[]) {
|
||||
use_prewarmed_process(int argc, char *argv[], char *envp[]) {
|
||||
char *env_addr = getenv("KITTY_PREWARM_SOCKET");
|
||||
if (!env_addr || !*env_addr || !is_prewarmable(argc, argv)) return;
|
||||
env_addr = check_socket_addr(env_addr);
|
||||
@ -698,6 +698,12 @@ use_prewarmed_process(int argc, char *argv[]) {
|
||||
to_child_tty.buf = from_child_tty.buf + IO_BUZ_SZ;
|
||||
#undef fail
|
||||
|
||||
while (*envp) {
|
||||
if (strncmp(*envp, "KITTY_PREWARM_SOCKET=", 2) == 0) {
|
||||
sprintf(*envp, "KITTY_PWPR=%s", child_tty_name);
|
||||
}
|
||||
envp++;
|
||||
}
|
||||
loop();
|
||||
flush_data();
|
||||
cleanup();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user