chiark / gitweb /
main: minor code modernization for initializing the console
[elogind.git] / src / shared / util.c
index d6cea4d208371e6275648c7cbabba2c9d1c4c78e..18d40f398faace72f499a062ac42e9f8c15918ce 100644 (file)
@@ -2084,12 +2084,14 @@ fail:
 }
 
 int release_terminal(void) {
-        int r = 0;
-        struct sigaction sa_old, sa_new = {
+        static const struct sigaction sa_new = {
                 .sa_handler = SIG_IGN,
                 .sa_flags = SA_RESTART,
         };
-        _cleanup_close_ int fd;
+
+        _cleanup_close_ int fd = -1;
+        struct sigaction sa_old;
+        int r = 0;
 
         fd = open("/dev/tty", O_RDWR|O_NOCTTY|O_NDELAY|O_CLOEXEC);
         if (fd < 0)