Module Name:    src
Committed By:   jmcneill
Date:           Mon Dec 12 16:39:16 UTC 2011

Modified Files:
        src/sys/arch/usermode/dev: ttycons.c
        src/sys/arch/usermode/include: thunk.h
        src/sys/arch/usermode/usermode: thunk.c

Log Message:
make sure to set O_ASYNC on stdin to enable ttycons "interrupts"


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/usermode/dev/ttycons.c
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/usermode/include/thunk.h
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/usermode/usermode/thunk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/usermode/dev/ttycons.c
diff -u src/sys/arch/usermode/dev/ttycons.c:1.9 src/sys/arch/usermode/dev/ttycons.c:1.10
--- src/sys/arch/usermode/dev/ttycons.c:1.9	Mon Dec 12 16:06:15 2011
+++ src/sys/arch/usermode/dev/ttycons.c	Mon Dec 12 16:39:16 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: ttycons.c,v 1.9 2011/12/12 16:06:15 jmcneill Exp $ */
+/* $NetBSD: ttycons.c,v 1.10 2011/12/12 16:39:16 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill <jmcne...@invisible.ca>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ttycons.c,v 1.9 2011/12/12 16:06:15 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ttycons.c,v 1.10 2011/12/12 16:39:16 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -136,6 +136,8 @@ ttycons_attach(device_t parent, device_t
 		panic("couldn't establish ttycons softint handler\n");
 
 	thunk_signal(SIGIO, ttycons_intr);
+	if (thunk_set_stdin_sigio(true) != 0)
+		panic("couldn't enable stdin async mode");
 }
 
 void

Index: src/sys/arch/usermode/include/thunk.h
diff -u src/sys/arch/usermode/include/thunk.h:1.36 src/sys/arch/usermode/include/thunk.h:1.37
--- src/sys/arch/usermode/include/thunk.h:1.36	Sun Dec 11 22:33:49 2011
+++ src/sys/arch/usermode/include/thunk.h	Mon Dec 12 16:39:16 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.h,v 1.36 2011/12/11 22:33:49 jmcneill Exp $ */
+/* $NetBSD: thunk.h,v 1.37 2011/12/12 16:39:16 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcne...@invisible.ca>
@@ -92,6 +92,7 @@ int	thunk_swapcontext(ucontext_t *, ucon
 int	thunk_tcgetattr(int, struct thunk_termios *);
 int	thunk_tcsetattr(int, int, const struct thunk_termios *);
 
+int	thunk_set_stdin_sigio(int);
 int	thunk_pollchar(void);
 int	thunk_getchar(void);
 void	thunk_putchar(int);

Index: src/sys/arch/usermode/usermode/thunk.c
diff -u src/sys/arch/usermode/usermode/thunk.c:1.41 src/sys/arch/usermode/usermode/thunk.c:1.42
--- src/sys/arch/usermode/usermode/thunk.c:1.41	Sun Dec 11 22:33:49 2011
+++ src/sys/arch/usermode/usermode/thunk.c	Mon Dec 12 16:39:16 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.c,v 1.41 2011/12/11 22:33:49 jmcneill Exp $ */
+/* $NetBSD: thunk.c,v 1.42 2011/12/12 16:39:16 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcne...@invisible.ca>
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #ifdef __NetBSD__
-__RCSID("$NetBSD: thunk.c,v 1.41 2011/12/11 22:33:49 jmcneill Exp $");
+__RCSID("$NetBSD: thunk.c,v 1.42 2011/12/12 16:39:16 jmcneill Exp $");
 #endif
 
 #include <sys/types.h>
@@ -321,6 +321,21 @@ thunk_tcsetattr(int fd, int action, cons
 }
 
 int
+thunk_set_stdin_sigio(int onoff)
+{
+	int flags;
+
+	flags = fcntl(STDIN_FILENO, F_GETFL, 0);
+
+	if (onoff)
+		flags |= O_ASYNC;
+	else
+		flags &= ~O_ASYNC;
+
+	return fcntl(STDIN_FILENO, F_SETFL, flags);
+}
+
+int
 thunk_pollchar(void)
 {
 	struct pollfd fds[1];

Reply via email to