⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kbd.c

📁 早期freebsd实现
💻 C
字号:
#include "jove.h"#include <signal.h>#include <errno.h>#ifdef	PIPEPROCS	/* only needed for systems with iproc-pipes */#ifdef	BSD_SIGS# define pause()	sigpause(0L)#endifstruct header {	int	pid,		nbytes;	char	buf[10];};#define HEADER_SIZE	(2 * sizeof (int))/* JOVE sends SIGQUIT whenever it wants the kbd process (this program)   to stop competing for input from the keyboard.  JOVE does this when   JOVE realizes that there are no more interactive processes running.   The reason we go through all this trouble is that JOVE slows down   a lot when it's getting its keyboard input via a pipe. */private SIGRESULT strt_read proto((int));private SIGRESULThold_read(junk)int	junk;	/* passed in when invoked by a signal; of no interest */{	signal(KBDSIG, strt_read);	pause();	SIGRETURN;}private SIGRESULTstrt_read(junk)int	junk;{	signal(KBDSIG, hold_read);	SIGRETURN;}intmain(argc, argv)int	argc;char	**argv;{	struct header	header;	int	pid,		n;	signal(SIGINT, SIG_IGN);	pid = getpid();	header.pid = pid;	hold_read(0);	for (;;) {		n = read(0, (UnivPtr) header.buf, sizeof (header.buf));		if (n == -1) {			if (errno != EINTR)				break;			continue;		}		header.nbytes = n;		write(1, (UnivPtr) &header, HEADER_SIZE + n);	}	return 0;}#else	/* !PIPEPROCS */intmain(){	return 0;}#endif	/* !PIPEPROCS */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -