linux alarm函数
来源:互联网 发布:如何绕过公司网络限制 编辑:程序博客网 时间:2024/06/03 20:40
首先 man alarm
NAME
alarm - set an alarm clock for delivery of a signal
SYNOPSIS
#include <unistd.h>
unsigned int alarm(unsigned int seconds);
DESCRIPTION
alarm() arranges for a SIGALRM signal to be delivered to the process in seconds seconds.
If seconds is zero, no new alarm() is scheduled.
In any event any previously set alarm() is cancelled.
RETURN VALUE
alarm() returns the number of seconds remaining until any previously scheduled alarm was due to be delivered,
or zero if there was no previously scheduled alarm.
测试程序
#include<stdio.h>
#include<signal.h>
#include<unistd.h>
void alarm_test(int i) //需要加int i
{
printf("hello world\n");
signal(SIGALRM,alarm_test);
alarm(3);
}
int main()
{
int i ;
int a =0;
alarm_test(i);
for(i=1;i<17;i++)
{
printf("sleep %d s\n",i);
sleep(1);
if(i == 7)
{
a = alarm(5); //重新设置定时时间
// a = alarm(0); //取消定时任务
printf("a=[%d]\n",a); //返回剩余时间
}
}
return 0;
}
- Linux alarm闹钟函数
- linux alarm函数
- linux alarm函数使用
- linux alarm函数
- linux alarm函数
- linux alarm函数简介
- linux C之alarm函数
- linux C之alarm函数
- linux alarm和可重入函数
- linux C之alarm函数
- linux C之alarm函数(更改)
- linux C之alarm函数(更改)
- alarm函数
- alarm 函数
- alarm 函数
- alarm函数
- alarm()函数
- alarm 函数time函数
- C++栈的实现
- web系统用户认证的密码摘要
- JAVA _控制语句
- Android Thing专题5 I2C
- 关于EXCEL表格中“天、时、分转换小时”的操作方法
- linux alarm函数
- idea热部署时,不能正确配置解决
- UVA
- Yii2使用表单上传文件
- thinking in java——0412学习笔记
- springboot(七):springboot+mybatis多数据源最简解决方案
- lintcode(534)打劫房屋 II
- 欢迎使用CSDN-markdown编辑器
- 使用<jsp:include>,不想写死URL,动态生成URL的解决办法