完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
#include #include <time.h> #include #include #include #include #include #include void m_sa_sigaction(int i, siginfo_t *siginfo, void * v) { printf("do something @ heren"); } int main(int argc, char *argv[]) { clockid_t clockid = CLOCK_MONOTONIC; int signum = SIGUSR1; struct sigevent sevp = { .sigev_notify = SIGEV_SIGNAL, /* Notification method */ /*Notify the process by sending the signal specified in sigev_signo.*/ .sigev_signo = signum, /* Notification signal */ .sigev_value.sival_int = 0, /* Data passed with notification */ }; timer_t timerid; struct itimerspec new_value = { .it_interval = { .tv_sec = 1, .tv_nsec = 0, }, /* Timer interval */ .it_value = { .tv_sec = 0, .tv_nsec = 1, }, /* Initial expiration */ }; struct sigaction act = { .sa_sigaction = m_sa_sigaction, .sa_flags = SA_SIGINFO, }; sigemptyset(&act.sa_mask); if(sigaction(signum, &act, NULL) == -1){ perror("sigaction"); } if(timer_create(clockid, &sevp, &timerid) == -1){ perror("timer_createn"); } if(timer_settime(timerid, 0, &new_value, NULL) == -1){ perror("timer_settimen"); } while(1) { sleep(1); fprintf(stderr, "#"); } } |
|
相关推荐
|
|
飞凌嵌入式ElfBoard ELF 1板卡-CAN编程示例之开发板测试
240 浏览 0 评论
该问题是用APP给芯海科技的CST92F25芯片发指令是出现的
2066 浏览 1 评论
688 浏览 0 评论
1425 浏览 1 评论
2159 浏览 1 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-19 23:22 , Processed in 0.488662 second(s), Total 65, Slave 48 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号