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

📄 event.c

📁 这是一个同样来自贝尔实验室的和UNIX有着渊源的操作系统, 其简洁的设计和实现易于我们学习和理解
💻 C
字号:
#include <u.h>#include <libc.h>#include <draw.h>#include <event.h>#include "cons.h"#define	BUFSIZ	4000extern int	outfd;int	hostpid;voidedie(void){	static int dead = 0;	if(dead++ > 0) return;	close(outfd);	postnote(PNGROUP, getpid(), "exit");}static intstart_host(void){	int	fd;	cs = consctl();	if(cs == 0){		perror("consctl");		exits("consctl");	}	switch((hostpid = rfork(RFPROC|RFNAMEG|RFFDG|RFNOTEG))) {	case 0:		fd = open("/dev/cons", OREAD);		dup(fd,0);		if(fd != 0)			close(fd);		fd = open("/dev/cons", OWRITE);		dup(fd,1);		dup(fd,2);		if(fd != 1 && fd !=2)			close(fd);		execl("/bin/rc","rcX",nil);		fprint(2,"failed to start up rc\n");		_exits("rc");	case -1:		fprint(2,"rc startup: fork error\n");		_exits("rc_fork");	}	return open("/mnt/cons/cons/data", ORDWR);}voidebegin(int Ehost){	atexit(edie);	einit(Emouse|Ekeyboard);	outfd = start_host();	if( estart(Ehost, outfd, BUFSIZ) != Ehost) {		exits("event init error");	}}voidsend_interrupt(void){	postnote(PNGROUP, hostpid,"interrupt");}

⌨️ 快捷键说明

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