[PATCH app/xconsole] Open /dev/console with NOCTTY and O_NONBLOCK flags

Arvind Umrao arvind.umrao at oracle.com
Thu Aug 23 21:14:23 PDT 2012


In some cases, for SPARC servers, special files like fifo need to open in nonblocking mode otherwise whole xconsole GUI freezes. Also /dev/console is often a terminal device.  So I am opening /dev/console with NOCTTY and O_NONBLOCK flags.

Signed-off-by: Arvind Umrao <arvind.umrao at oracle.com>
---
 xconsole.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/xconsole.c b/xconsole.c
index adbc298..d8067e5 100644
--- a/xconsole.c
+++ b/xconsole.c
@@ -334,7 +334,10 @@ OpenConsole(void)
 	    regularFile = FALSE;
 	    if (access(app_resources.file, R_OK) == 0)
 	    {
-		input = fopen (app_resources.file, "r");
+		int fd  = open (app_resources.file, O_RDONLY | O_NONBLOCK | O_NOCTTY);
+ 		if (fd != -1)
+		    input = fdopen (fd, "r");
+
 		if (input)
 		    if (!stat(app_resources.file, &sbuf) &&
 			S_ISREG( sbuf.st_mode ) )
-- 
1.7.9.2



More information about the xorg-devel mailing list