]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
exec-util: drop handling of ENXIO in opening /dev/tty
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 3 Dec 2024 09:50:25 +0000 (18:50 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 11 Dec 2024 23:35:16 +0000 (08:35 +0900)
This effectively reverts 0bcf1679007e71d1d37666c10ab1f8d46de8d570.

The handling is not necessary anymore after 61242b1f0f9cac399deb67c88c3b62d38218dba3.

src/shared/exec-util.c

index e044cea33002825460c2e601ff0dbbbad2915e3e..725962ef83ce34edf00c6c9520b2ec5299d92469 100644 (file)
@@ -596,32 +596,26 @@ int _fork_agent(const char *name, const int except[], size_t n_except, pid_t *re
                  * stdin around. */
                 fd = open("/dev/tty", stdin_is_tty ? O_WRONLY : (stdout_is_tty && stderr_is_tty) ? O_RDONLY : O_RDWR);
                 if (fd < 0) {
-                        if (errno != ENXIO) {
-                                log_error_errno(errno, "Failed to open /dev/tty: %m");
-                                _exit(EXIT_FAILURE);
-                        }
-
-                        /* If we get ENXIO here we have no controlling TTY even though stdout/stderr are
-                         * connected to a TTY. That's a weird setup, but let's handle it gracefully: let's
-                         * skip the forking of the agents, given the TTY setup is not in order. */
-                } else {
-                        if (!stdin_is_tty && dup2(fd, STDIN_FILENO) < 0) {
-                                log_error_errno(errno, "Failed to dup2 /dev/tty to STDIN: %m");
-                                _exit(EXIT_FAILURE);
-                        }
+                        log_error_errno(errno, "Failed to open /dev/tty: %m");
+                        _exit(EXIT_FAILURE);
+                }
 
-                        if (!stdout_is_tty && dup2(fd, STDOUT_FILENO) < 0) {
-                                log_error_errno(errno, "Failed to dup2 /dev/tty to STDOUT: %m");
-                                _exit(EXIT_FAILURE);
-                        }
+                if (!stdin_is_tty && dup2(fd, STDIN_FILENO) < 0) {
+                        log_error_errno(errno, "Failed to dup2 /dev/tty to STDIN: %m");
+                        _exit(EXIT_FAILURE);
+                }
 
-                        if (!stderr_is_tty && dup2(fd, STDERR_FILENO) < 0) {
-                                log_error_errno(errno, "Failed to dup2 /dev/tty to STDERR: %m");
-                                _exit(EXIT_FAILURE);
-                        }
+                if (!stdout_is_tty && dup2(fd, STDOUT_FILENO) < 0) {
+                        log_error_errno(errno, "Failed to dup2 /dev/tty to STDOUT: %m");
+                        _exit(EXIT_FAILURE);
+                }
 
-                        fd = safe_close_above_stdio(fd);
+                if (!stderr_is_tty && dup2(fd, STDERR_FILENO) < 0) {
+                        log_error_errno(errno, "Failed to dup2 /dev/tty to STDERR: %m");
+                        _exit(EXIT_FAILURE);
                 }
+
+                fd = safe_close_above_stdio(fd);
         }
 
         /* Count arguments */