From e0a627c141935c65b43c83c9107fce56faad6b20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 25 Sep 2007 10:51:50 +0000 Subject: [PATCH] The TTY now only allows session leaders to open it; consoled only called setsid() too late, it does it now before starting the console. This fixes bug #1502, and also allows to debug the GUI servers again. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22300 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/tests/system/consoled/consoled.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/tests/system/consoled/consoled.cpp b/src/tests/system/consoled/consoled.cpp index bf311003d4..238f00c8b3 100644 --- a/src/tests/system/consoled/consoled.cpp +++ b/src/tests/system/consoled/consoled.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2004-2005, Haiku. All rights reserved. + * Copyright 2004-2007, Haiku. All rights reserved. * Distributed under the terms of the MIT License. * * Copyright 2002, Travis Geiselbrecht. All rights reserved. @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -206,7 +207,7 @@ start_console(struct console *con) con->tty_slave_fd = open(name, O_RDWR); if (con->tty_slave_fd < 0) { - fprintf(stderr, "Could not open tty!\n"); + fprintf(stderr, "Could not open tty %s: %s!\n", name, strerror(errno)); close(con->tty_master_fd); } else { // set default mode @@ -316,15 +317,15 @@ main(int argc, char **argv) { int err; + // we're a session leader + setsid(); + err = start_console(&gConsole); if (err < 0) { printf("consoled: error %d starting console\n", err); return err; } - // we're a session leader - setsid(); - // move our stdin and stdout to the console dup2(gConsole.tty_slave_fd, 0); dup2(gConsole.tty_slave_fd, 1);