From aff3dba84c75fba62fe663e77c6a61d3b2da1d77 Mon Sep 17 00:00:00 2001 From: Frank Benkstein Date: Sat, 11 Aug 2007 17:55:57 +0200 Subject: [PATCH] src/vlock-new.c: don't rely on /dev/tty, use stdin instead --- src/vlock-new.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/vlock-new.c b/src/vlock-new.c index 65ba957..1ea4495 100644 --- a/src/vlock-new.c +++ b/src/vlock-new.c @@ -78,7 +78,7 @@ static char *get_console_name(int n) { /* Run vlock-all on a new console. */ int main(void) { - int consfd; + int consfd = STDIN_FILENO; int old_vtno; int vtno; int vtfd; @@ -86,17 +86,11 @@ int main(void) { int pid = -1; int status; - /* open the current terminal */ - if ((consfd = open("/dev/tty", O_RDWR)) < 0) { - perror("vlock-new: could not open /dev/tty"); - exit (111); - } - /* get the number of the currently active console */ old_vtno = get_active_console(consfd); if (old_vtno < 0) { - /* the current terminal does not belong to the virtual console */ + /* stdin is does not a virtual console */ (void) close(consfd); /* XXX: add optional PAM check here */ -- 2.11.4.GIT