interrupt.c

来自「apue第二版每一章节的c语言源码」· C语言 代码 · 共 50 行

C
50
字号
#include	"lprps.h"static voidsig_int(int signo)		/* SIGINT handler */{	intr_flag = 1;	return;}/* This function is called after SIGINT has been delivered, * and the main loop has recognized it.  (It not called as * a signal handler, set_intr() above is the handler.) */voidhandle_intr(void){	char	c;	intr_flag = 0;	clear_intr();			/* turn signal off */	set_alrm(30);		/* 30 second timeout to interrupt printer */	tty_flush();			/* discard any queued output */	c = '\003';	block_write(&c, 1);		/* Control-C interrupts the PS job */	block_write(&eofc, 1);	/* followed by EOF */	proc_upto_eof(1);		/* read & ignore up through EOF */	clear_alrm();	get_page(&end_page);	do_acct();	exit(EXIT_SUCCESS);		/* success since user lprm'ed the job */}voidset_intr(void)		/* enable signal handler */{	if (signal_intr(SIGINT, sig_int) == SIG_ERR)		log_sys("set_intr: signal_intr error");}voidclear_intr(void)	/* ignore signal */{	if (signal(SIGINT, SIG_IGN) == SIG_ERR)		log_sys("clear_intr: signal error");}

⌨️ 快捷键说明

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