mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-09 19:36:47 +00:00
* remove `ret_from_syscall` *修复ps2键盘驱动程序inode在进程fork的时候导致死锁的问题. *更新: VFS每次拷贝文件描述符的时候,都会去调用inode的open函数 --------- Co-authored-by: longjin <longjin@RinGoTek.cn>
58 lines
1.1 KiB
C
58 lines
1.1 KiB
C
/**
|
|
* @file main.c
|
|
* @author longjin (longjin@RinGoTek.cn)
|
|
* @brief 测试signal用的程序
|
|
* @version 0.1
|
|
* @date 2022-12-06
|
|
*
|
|
* @copyright Copyright (c) 2022
|
|
*
|
|
*/
|
|
|
|
/**
|
|
* 测试signal的kill命令的方法:
|
|
* 1.在DragonOS的控制台输入 exec bin/test_signal.elf &
|
|
* 请注意,一定要输入末尾的 '&',否则进程不会后台运行
|
|
* 2.然后kill对应的进程的pid (上一条命令执行后,将会输出这样一行:"[1] 生成的pid")
|
|
*
|
|
*/
|
|
|
|
#include <math.h>
|
|
#include <signal.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
#include <unistd.h>
|
|
|
|
bool handle_ok = false;
|
|
|
|
void handler(int sig)
|
|
{
|
|
printf("handle %d\n", sig);
|
|
handle_ok = true;
|
|
}
|
|
|
|
int main()
|
|
{
|
|
printf("Test signal running...\n");
|
|
signal(SIGKILL, &handler);
|
|
printf("registered.\n");
|
|
|
|
clock_t last = clock();
|
|
|
|
while (1)
|
|
{
|
|
if ((clock() - last) / CLOCKS_PER_SEC >= 1)
|
|
{
|
|
// printf("Test signal running\n");
|
|
last = clock();
|
|
}
|
|
if (handle_ok)
|
|
{
|
|
printf("Handle OK!\n");
|
|
handle_ok = false;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
} |