diff --git a/src/run/run.c b/src/run/run.c index 99aad5df77..9f9e56a3c1 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -1836,6 +1836,14 @@ static void run_context_check_done(RunContext *c) { log_error_errno(r, "Failed to drain PTY forwarder: %m"); return (void) sd_event_exit(c->event, EXIT_FAILURE); } + + /* Tell the forwarder to exit on the next vhangup(), so that we still flush out what might be queued + * and exit then. */ + r = pty_forward_honor_vhangup(c->forward); + if (r < 0) { + log_error_errno(r, "Failed to make PTY forwarder honor vhangup(): %m"); + return (void) sd_event_exit(c->event, EXIT_FAILURE); + } } static int map_job(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) {