sleep1.c

来自「unix环境高级编程 配套源代码 学习学习啊」· C语言 代码 · 共 19 行

C
19
字号
#include	<signal.h>#include	<unistd.h>static voidsig_alrm(int signo){	return;	/* nothing to do, just return to wake up the pause */}unsigned intsleep1(unsigned int nsecs){	if (signal(SIGALRM, sig_alrm) == SIG_ERR)		return(nsecs);	alarm(nsecs);		/* start the timer */	pause();			/* next caught signal wakes us up */	return( alarm(0) );	/* turn off timer, return unslept time */}

⌨️ 快捷键说明

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