From: Yu Watanabe Date: Mon, 28 Jul 2025 19:34:01 +0000 (+0900) Subject: run: make PTY forwarder honor vhangup() after service finished X-Git-Tag: v258-rc2~38^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b749f77ad0acaed6704fbc5353d2d5352e243173;p=thirdparty%2Fsystemd.git run: make PTY forwarder honor vhangup() after service finished Like we already do in machinectl. --- diff --git a/src/run/run.c b/src/run/run.c index 99aad5df776..9f9e56a3c19 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) {