From: ian Date: Sat, 7 Jun 2008 22:51:42 +0000 (+0000) Subject: new --stdin-monitor option X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=325aaa7fd29a2798d376556032706713f77122b3;p=trains.git new --stdin-monitor option --- diff --git a/hostside/evdev-manip.c b/hostside/evdev-manip.c index 84a04d0..34ec916 100644 --- a/hostside/evdev-manip.c +++ b/hostside/evdev-manip.c @@ -7,6 +7,7 @@ * ^^^^^^^^^^^^^^^^^^^^ * this part is in /proc/bus/usb/devices * and can thus be specified by caller + * --stdin-monitor */ #include "common.h" @@ -36,7 +37,7 @@ static int ndevices; static Device *devices; static Mode mode; -static int grab; +static int grab, stdinmonitor; static const char *expect_sysfs; static void pr_hex(unsigned long value) { printf("%#lx",value); } @@ -128,25 +129,37 @@ static void dump_died(Device *d, int revents, int readr, int readc, int e) { static void mainloop(void) { struct pollfd *polls; - int i, r; + int i, r, npolls; - polls= mmalloc(sizeof(*polls)*ndevices); + npolls= ndevices + stdinmonitor; + polls= mmalloc(sizeof(*polls)*npolls); for (i=0; i0); + if (stdinmonitor) { + if (polls[ndevices].revents) { + printf("quitting-stdin-polled %#x\n", polls[ndevices].revents); + exit(0); + } + } + for (i=0; imainloop();