How can I combine SIGUSR1 with the return key?

How can I combine SIGUSR1 with the return key?

Post by David C » Wed, 04 Sep 1996 04:00:00



Dear Netters:

    I wonder how I can combine the SIGUSR1 with the return key?
Which means each time I hit return key, I will generate a SIGUSR1
and so I can trap it.

    Thanks.

    David

 
 
 

How can I combine SIGUSR1 with the return key?

Post by Andrew Gier » Fri, 06 Sep 1996 04:00:00


 David> Dear Netters:

 David>     I wonder how I can combine the SIGUSR1 with the return key?
 David> Which means each time I hit return key, I will generate a SIGUSR1
 David> and so I can trap it.

You can't.

(Oh, I suppose if you use a Unix flavour that has STREAMS ttys, you could
probably write a module for this, but that strikes me as too perverse.)

You can, if you like, set up the return key to generate SIGINT, SIGQUIT
or (usually) SIGTSTP, since these are the signals normally generated by
the terminal driver (see tcsetattr() etc. for how to do this). Just make
sure you put things back where they were when you exit...

--

Unsolicited email (technical questions or otherwise) is NOT welcome.

 
 
 

How can I combine SIGUSR1 with the return key?

Post by Stephen Bayn » Fri, 06 Sep 1996 04:00:00



:  David> Dear Netters:

:  David>     I wonder how I can combine the SIGUSR1 with the return key?
:  David> Which means each time I hit return key, I will generate a SIGUSR1
:  David> and so I can trap it.

: You can't.

: (Oh, I suppose if you use a Unix flavour that has STREAMS ttys, you could
: probably write a module for this, but that strikes me as too perverse.)

Or you can write another program that sits between your program and the
real terminal and filters all the input. Base it on something like script
or r(em)sh.

: You can, if you like, set up the return key to generate SIGINT, SIGQUIT
: or (usually) SIGTSTP, since these are the signals normally generated by
: the terminal driver (see tcsetattr() etc. for how to do this). Just make
: sure you put things back where they were when you exit...

The handlers for these can then raise SIGUSR1.

You could also have the terminal in cooked (normal) mode and try for SIGIO.

--

Philips Semiconductors Ltd
Southampton                                 My views are my own.
United Kingdom
 Are you using ISO8859-1? Do you see ? as copyright, as division and ? as 1/2?

 
 
 

How can I combine SIGUSR1 with the return key?

Post by Frank Pilhof » Sat, 07 Sep 1996 04:00:00



>: You can, if you like, set up the return key to generate SIGINT, SIGQUIT
>: or (usually) SIGTSTP, since these are the signals normally generated by
>: the terminal driver (see tcsetattr() etc. for how to do this). Just make
>: sure you put things back where they were when you exit...
>The handlers for these can then raise SIGUSR1.

 ... which doesn't make any sense since the signal handler can't tell
where the signal did come from.

 A real solution is possible, though, by forking. One of the forks would
read data from the keyboard and pass on the data via IPC or sockets, and
send the desired SIGUSR1 if the return key comes along. Not quite a
sensible thing to do, but possible ...
 Anyway, this sounds like the How-To-Read-Keyboard-During-Lengthy-Cal-
culation-Problem. Maybe we should just point to the select() manpage?

        Frank

--

 | Darmstaedter Str. 22                     http://www.uni-frankfurt.de/~fp/ |
 | D-63225 Langen, Germany                              RAD Host             |
 +---------------------------------------------------------------------------+
 | It's no use. She'll never see me as anything - but a monster.   The Beast |