|
|
1.1 ! root 1: #include "jove.h" ! 2: #include <signal.h> ! 3: #include <errno.h> ! 4: ! 5: ! 6: #ifdef BSD_SIGS ! 7: # define pause() sigpause(0L) ! 8: #endif ! 9: ! 10: struct header { ! 11: int pid, ! 12: nbytes; ! 13: char buf[10]; ! 14: }; ! 15: ! 16: #define HEADER_SIZE (2 * sizeof (int)) ! 17: ! 18: /* JOVE sends SIGQUIT whenever it wants the kbd process (this program) ! 19: to stop competing for input from the keyboard. JOVE does this when ! 20: JOVE realizes that there are no more interactive processes running. ! 21: The reason we go through all this trouble is that JOVE slows down ! 22: a lot when it's getting its keyboard input via a pipe. */ ! 23: ! 24: static SIGRESULT strt_read proto((int)); ! 25: ! 26: static SIGRESULT ! 27: hold_read(junk) ! 28: int junk; /* passed in when invoked by a signal; of no interest */ ! 29: { ! 30: signal(SIGQUIT, strt_read); ! 31: pause(); ! 32: SIGRETURN; ! 33: } ! 34: ! 35: static SIGRESULT ! 36: strt_read(junk) ! 37: int junk; ! 38: { ! 39: signal(SIGQUIT, hold_read); ! 40: SIGRETURN; ! 41: } ! 42: ! 43: int ! 44: main(argc, argv) ! 45: int argc; ! 46: char **argv; ! 47: { ! 48: struct header header; ! 49: int pid, ! 50: n; ! 51: ! 52: signal(SIGINT, SIG_IGN); ! 53: pid = getpid(); ! 54: header.pid = pid; ! 55: ! 56: hold_read(0); ! 57: for (;;) { ! 58: n = read(0, header.buf, sizeof (header.buf)); ! 59: if (n == -1) { ! 60: if (errno != EINTR) ! 61: break; ! 62: continue; ! 63: } ! 64: header.nbytes = n; ! 65: write(1, (UnivPtr) &header, HEADER_SIZE + n); ! 66: } ! 67: return 0; ! 68: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.