[COLUG] closing stdin, forking, and deamons

Jim Dinan jdinan at crystalorb.net
Sat Nov 13 15:46:45 EST 2004


I didn't see any responses on this so I'll lead off ...

I bet you could do it with a custom USB HID module.  If you hack the 
kernel a little you might be able to prevent USB beyboards from 
registering with the console but still be able to read them from /dev/input.

The init approach would work too assuming you don't want to run any 
other tasks on the system, but IMHO a custom HID module is a much 
cleaner solution.  Also if you only hack USB HID, you leave the option 
open to connect a PS2 keyboard to talk to the box if you need to.

Can you explain you project a little better?  Why are you so worried 
about disconnecting the keyboard from the console?

- jim.

Aaron Howard wrote:
> Hey all...
> 
> I can't come up with a simple, clear, precise way to put this; so, bear
> with me.
> 
> Premise:
> 
> (1) multiple USB HID keyboards on single host
> (2) all those keyboards cause input into the console
> (3) My app reads each device via /dev/input/event interfaces
> (4) I want the system to discard ALL input coming from any keyboard
> 
> Making sense so far?
> 
> So, does it make sense to:
> 
> (1) launch via init (cut-down sysinit script):
> 	#!/bin/sh
> 	...do a few important things here first
> 	python app.py /dev/input/event1 &
> 	python app.py /dev/input/event2 &
> 	...now how do I close stdin for the console/init process?
> 
> (2) daemonize it (again via init's sysinit script):
> 	#!/bin/sh
> 	...do a few important things here first
> 	# this python module forks and exits the parent process
> 	# and closes its stdin, stdout, and stderr 
> 	python mydaemon.py 
> 	# still how do I close stdin for the console/init process?
> 
> (3) forget sysinit script altogether and launch via inittab:
> 	# basic inittab
> 	id:1:initdefault:
> 	1:1:respawn:/usr/bin/python myapp.py /dev/input/event1
> 	2:1:respawn:/usr/bin/python myapp.py /dev/input/event2
> 
> (4) launch as a daemon via inittab:
> 	# basic inittab
> 	id:1:initdefault:
> 	1:1:wait:/usr/bin/python mydaemon.py
> 
> (5) skip init altogether and make python the init process:
> 	boot init=/usr/bin/python /appdir/myapp.py
> 
> No matter what I end up doing, I can make the python app detach/close
> its stdin so it won't ever see the keyboard input...but what then do I
> do to make the init process ignore keyboard input?
> 
> My mind is befuddled...
> 
> -Aaron
> _______________________________________________
> colug1 mailing list colug1 at colug.net
> http://www.colug.net/mailman/listinfo/colug1

-- 
. -~^~-.-~^~-.-~^~-.-~^~-.-~^~-.-~^~-.-~^~-.-~^~-.-~^~-.-~^~-.-~^~- .
. James Dinan <jdinan at crystalorb.net>   http://chair.crystalorb.net .
.        "Stell Dir vor, es ist Krieg und keiner geht hin."         .



More information about the colug mailing list