📄 interrupt.c
字号:
#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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -