You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
537 B
31 lines
537 B
#include<stdio.h>
|
|
#include<signal.h>
|
|
#include<unistd.h>
|
|
void sigAlrm(int signal)
|
|
{}
|
|
|
|
unsigned int mysleep(unsigned int second)
|
|
{
|
|
struct sigaction sig,osig;
|
|
sig.sa_handler = sigAlrm;
|
|
sigemptyset(&sig.sa_mask);
|
|
sig.sa_flags = 0;
|
|
|
|
sigaction(SIGALRM,&sig,&osig);
|
|
alarm(second);
|
|
pause();
|
|
unsigned int ret = alarm(0);
|
|
sigaction(SIGALRM,&sig,NULL);
|
|
return ret;
|
|
}
|
|
|
|
int main()
|
|
{
|
|
while(1)
|
|
{
|
|
mysleep(2);
|
|
printf("sleep 2 second\n");
|
|
}
|
|
return 0;
|
|
}
|