]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
run: make PTY forwarder honor vhangup() after service finished 38385/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 28 Jul 2025 19:34:01 +0000 (04:34 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 29 Jul 2025 16:15:29 +0000 (01:15 +0900)
Like we already do in machinectl.

src/run/run.c

index 99aad5df776d3be588ae69b012d2d7af82cbbc1f..9f9e56a3c19d2fbc1eb0e9af782bd3579823df89 100644 (file)
@@ -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) {