lear@aramis.RUTGERS.EDU (eliot lear) (05/02/87)
Hello all, I would like to do the following in UNIX but I am not quite sure how... My problem: I want to place a command on a key. It is an old TOPS-20ism that I enjoyed to place commands on keys, such as accessing your editor with one character, like C-K or C-E. The program I would like to put on a key is a FAST network send program. The problem is that I do not believe that UNIX allows for user definable interrupt characters and I do not know how to write the program without at least one interrupt character. Someone suggested using the quit character and one of my friends who has spent lots of time building TeX quickly killed (-9) the idea. My solution: I propose to place a group of ``slots'' in the ttychars struct and make minor changes to tty.c to allow for user definable interrupts. It would also require use of a signal. If I want to be lazy I could just use one of SIGUSR1 and SIGUSR2. Otherwise, I could probably hack it so that the user could specify the signal. My problem with my solution: I *really* don't want to add to the kernel unless absolutely necessary. If anyone knows of a method that allows me to set up my ``interrupt key'', please do not hesitate to mail or post!!! Thanks in advance.... -- [lear@rutgers.edu] [{harvard|pyrnj|seismo|ihnp4}!rutgers!lear]
mike@BRL.ARPA (Mike Muuss) (05/02/87)
You really don't need to modify the kernel to do what you wish. What you seem to want is a T(W)ENEX-style shell that runs in RAW or CBREAK mode, so that it can process each character as it is typed. There is no need to invent this capability again. I'm running a very sophisticated version of the CSH which is called TCSH (TWENEX CSH) -- you can bind functions to keys, or to key sequences, has command and file name completion, EMACS-style history editing, etc, etc. If you have a UNIX source license, contact <phil@brl.arpa> to arrange for a copy. If you prefer Bourne shell over CSH, no sweat. A similar set of features has been added to the Bourne shell, which is now called TBSH (TWENEX Bourne SHell). If you have a System-V R2 source license, contact <dpk@brl.arpa> to arrange for a copy. Best, -Mike
edw@ius2.cs.cmu.edu (Eddie Wyatt) (05/02/87)
Instead of setting up interrupt keys, how about using a polling technique combined with a timer interrupt. That is, setup an interrupt timer (using setitimer) with an interrupt handler (using signal or sigvec) such that the interrupt handler will poll stdin (using select and fileno(stdin) to get a file descriptor of stdin) to see if and charcters are out there? -- Eddie Wyatt
edw@ius2.cs.cmu.edu (Eddie Wyatt) (05/02/87)
Oh, another technique would be to fork a process just to take care of stdin (and stdout). Once one of the special characters comes in, just have the process signal (using kill) that an interrupt has occurred. -- Eddie Wyatt
bzs@bu-cs.BU.EDU (Barry Shein) (05/02/87)
Just a few thoughts: I assume that tcsh (a tops-20-ish version of csh with completion and ability to hang things on keys) is not sufficient? If you want it to always be there then no, if you only need it at shell level then yes. Of course in that case you could probably use aliases for a lot of things if you can bear to hit enter, not quite what you want either. I also won't mention that window systems like X allow arbitrary definitions of key caps (eg. I have keys that send things like ESC-> and ESC-< for you know who), ok that's not sufficient. GNU Emacs has a terminal emulator (a little more like a terminal than just a shell in a window) and the normal (did I say that?) keystroke hooks would work here. The other thing which would be fairly straightforward is get a copy of the UCB script command (dribble or photo) and hack it up to be more like an input version of crtsty, it's trapping everything and running it back thru a pty so anything would be quite possible. This is the most general solution. Hope it helps. -Barry Shein, Boston University
lear@aramis.rutgers.EDU (eliot lear) (05/03/87)
Again, Barry, thanks for your reply. Several points: First is that I do not want to rely upon any graphically oriented program to make this work, if possible. (Yes, I am a pain in the *** to satisfy ;-) I also do not want to have to implement this feature in every user program I am using. With regard to X, (to which I really don't want to be dependent upon) I still need to generate an interrupt somehow on the remote system. Using an idea like script is a thought. The question then turns to how script works. Does it actually see every character at any point? I believe it reads input based on the mode of program running underneath it and, therefore, wouldn't generally see input character by character. While I suspect it could be made to do reads character by character, I would like a little CPU left to crunch. I plan on looking over script closely, however, because it does look like a possibility. Again, thanks for your ideas, ...eliot
mike@BRL.ARPA (Mike Muuss) (05/05/87)
It's unclear to me what effect you are trying to achieve. Clearly, if you are using a BSD system, you can (almost) always type ^Z to suspend the current process and have the shell regain control of the terminal. On a related note, many places (BRL included) have modified the tty driver to provide ^T service directly from the kernel when the tty is in COOKED mode. I don't know if this is what you are trying to attempt. Best, -Mike
dce@mips.UUCP (05/05/87)
In article <7236@brl-adm.ARPA> mike@BRL.ARPA (Mike Muuss) writes: >It's unclear to me what effect you are trying to achieve. Clearly, if It sounds to me like the originator wants "our old friend" from last month - the tty filter. The idea is to come up with an interface that wraps around all processes, and lets you describe how the input and output are to be changed. For example, it would be nice to be able to say "if I type ESC<gap>3, where <gap> is no longer than .5 seconds, send the sequence 'funky'", or "if the output is _^H{x}, where {x} is any single character, change that to ESC[3m{x}ESC[0m". This mechanism could handle interrupt sending as well (if you really need asynchronous input like that). Such an interface should handle multiple user-selectable modes, understand raw and cbreak mode, and could incorporate editing capabilities (to get that damn stuff out of the shells where it destroys my typeahead). I designed such a system as a mental exercise (while bicycling to and from work), and have all kinds of ideas on what is needed. -- David Elliott {decvax,ucbvax,ihnp4}!decwrl!mips!dce
lear@aramis.UUCP (05/07/87)
While a tty filter would do the job, it would do it in a manner like telnetd, processing every character. This would seem to me to be very inefficient, if used on a large multiuser system. Yes, I expect the program I write to be heavily used as it was a favorite of ours on TOPS-20. I am still looking at several solutions outside the kernel and will post the results of my investigations sometime next week. Thanks again for your input, -- Eliot Lear Rutgers University Department of Mathematics [lear@rutgers.edu] [{harvard|pyrnj|seismo|ihnp4}!rutgers!lear]