字符驱动设备(4)

 

 1 #include <stdio.h>
 2 #include <signal.h>
 3 
 4 void my_signal_handler(int signum)
 5 {
 6     static int cnt = 0;
 7     printf("signal = %d, %d times\n",signum,cnt++);
 8 }
 9 
10 int main(int argc,char **argv)
11 {
12     signal(SIGUSR1,my_signal_handler);
13 
14     while(1)
15     {
16         sleep(1000);
17     }
18 
19     return 0;
20 }

上传编译之后:

命令行传入参数触发:

 由此得出结论:

我们可以在驱动里面设置信号,在应用程序中进行触发。

程序的完善如下:

猜你喜欢

转载自www.cnblogs.com/huanian/p/12955300.html