]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: use open_terminal() instead of open()
authorOwen W. Taylor <otaylor@fishsoup.net>
Tue, 18 Aug 2015 18:41:24 +0000 (14:41 -0400)
committerOwen W. Taylor <otaylor@fishsoup.net>
Tue, 18 Aug 2015 19:25:57 +0000 (15:25 -0400)
The open_terminal() function adds retries in case a terminal
is in the process of being closed when we open it, and should
generally be used to open a terminal. We especially need it
for code that a subsequent commit adds that reopens the terminal
at session shut-down time; such races would be more likely in
that case.

Found by Ray Strode.

src/login/logind-session.c

index e75c7c042e4cb8c500caace8b60ff0b8f55975b6..902abe0e42de43f7822789a656830509d46828dd 100644 (file)
@@ -986,7 +986,7 @@ static int session_open_vt(Session *s) {
                 return s->vtfd;
 
         sprintf(path, "/dev/tty%u", s->vtnr);
-        s->vtfd = open(path, O_RDWR | O_CLOEXEC | O_NONBLOCK | O_NOCTTY);
+        s->vtfd = open_terminal(path, O_RDWR | O_CLOEXEC | O_NONBLOCK | O_NOCTTY);
         if (s->vtfd < 0)
                 return log_error_errno(errno, "cannot open VT %s of session %s: %m", path, s->id);