]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/vconsole/vconsole-setup.c
Merge pull request #27867 from keszybz/vconsole-reload-again
[thirdparty/systemd.git] / src / vconsole / vconsole-setup.c
index 0c63f73bcf858c0ed5d274490095c809e8ee8473..1d5ee9ad4422ab0719142e3d857f441cc87eb454 100644 (file)
@@ -26,6 +26,7 @@
 #include "fileio.h"
 #include "io-util.h"
 #include "locale-util.h"
+#include "lock-util.h"
 #include "log.h"
 #include "proc-cmdline.h"
 #include "process-util.h"
@@ -589,6 +590,14 @@ int main(int argc, char **argv) {
 
         context_load_config(&c);
 
+        /* Take lock around the remaining operation to avoid being interrupted by a tty reset operation
+         * performed for services with TTYVHangup=yes. */
+        r = lock_generic(fd, LOCK_BSD, LOCK_EX);
+        if (r < 0) {
+                log_error_errno(r, "Failed to lock console: %m");
+                return EXIT_FAILURE;
+        }
+
         (void) toggle_utf8_sysfs(utf8);
         (void) toggle_utf8_vc(vc, fd, utf8);