diff --git a/kitty/prewarm.py b/kitty/prewarm.py index 4f272f7a1..35ca8da43 100644 --- a/kitty/prewarm.py +++ b/kitty/prewarm.py @@ -446,7 +446,7 @@ class SocketChild: def handle_death(self, status: int) -> None: if hasattr(os, 'waitstatus_to_exitcode'): status = os.waitstatus_to_exitcode(status) - self.conn.sendall(f'{status}:'.encode('ascii')) + self.conn.sendall(f'{status}'.encode('ascii')) self.conn.shutdown(socket.SHUT_RDWR) self.conn.close() @@ -626,7 +626,7 @@ def main(stdin_fd: int, stdout_fd: int, notify_child_death_fd: int, unix_socket: poll.unregister(scq.fd) scq.conn.shutdown(socket.SHUT_RD) scq.fork(get_all_non_child_fds()) - scq.child_id = child_pid_map[scq.pid] = next(child_id_counter) + scq.child_id = next(child_id_counter) except SocketClosed: socket_children.pop(q) continue diff --git a/prewarm-launcher.h b/prewarm-launcher.h index dfd977571..62298f723 100644 --- a/prewarm-launcher.h +++ b/prewarm-launcher.h @@ -289,10 +289,14 @@ read_child_data(void) { from_child_buf_pos += n; char *p = memchr(from_child_buf, ':', from_child_buf_pos); if (p && child_pid == 0) { + *p = 0; long cp = 0; if (!parse_long(from_child_buf, &cp)) { print_error("Could not parse child pid from prewarm socket", 0); return false; } if (cp == 0) { print_error("Got zero child pid from prewarm socket", 0); return false; } child_pid = cp; + memset(from_child_buf, 0, (p - from_child_buf) + 1); + from_child_buf_pos -= (p - from_child_buf) + 1; + if (from_child_buf_pos) memmove(from_child_buf, p + 1, from_child_buf_pos); } } return true; @@ -344,7 +348,7 @@ loop(void) { if (!read_child_data()) fail("reading information about child failed"); } if (poll_data[2].revents & POLLHUP) { - if (from_child_buf[0]) { char *p = memchr(from_child_buf, ':', sizeof(from_child_buf)); if (p) parse_int(p+1, &exit_status); } + if (from_child_buf[0]) { parse_int(from_child_buf, &exit_status); } return; } if (poll_data[2].revents & POLLOUT) {