mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-18 12:16:31 +00:00
signal的发送(暂时父子进程之间共享信号及相应的结构体) (#89)
* 解决由于spinlock.h中包含preempt_enable()带来的循环include问题 * new: 初步实现signal的数据结构 * new:signal相关数据结构 * fix: 解决bindings.rs报一堆警告的问题 * new: rust下的kdebug kinfo kwarn kBUG kerror宏 * 移动asm.h和cmpxchg.h * new: signal的发送(暂时只支持父子进程共享信号及处理函数)
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
#include <libc/dirent.h>
|
||||
#include <libc/errno.h>
|
||||
#include <libc/fcntl.h>
|
||||
#include <libc/include/signal.h>
|
||||
#include <libc/stddef.h>
|
||||
#include <libc/stdio.h>
|
||||
#include <libc/stdlib.h>
|
||||
@ -23,7 +24,7 @@ struct built_in_cmd_t shell_cmds[] = {
|
||||
{"cd", shell_cmd_cd}, {"cat", shell_cmd_cat}, {"exec", shell_cmd_exec}, {"ls", shell_cmd_ls},
|
||||
{"mkdir", shell_cmd_mkdir}, {"pwd", shell_cmd_pwd}, {"rm", shell_cmd_rm}, {"rmdir", shell_cmd_rmdir},
|
||||
{"reboot", shell_cmd_reboot}, {"touch", shell_cmd_touch}, {"about", shell_cmd_about}, {"free", shell_cmd_free},
|
||||
{"help", shell_help}, {"pipe", shell_pipe_test},
|
||||
{"help", shell_help}, {"pipe", shell_pipe_test}, {"kill", shell_cmd_kill},
|
||||
|
||||
};
|
||||
// 总共的内建命令数量
|
||||
@ -331,11 +332,14 @@ int shell_cmd_touch(int argc, char **argv)
|
||||
{
|
||||
int path_len = 0;
|
||||
char *file_path;
|
||||
bool alloc_full_path=false;
|
||||
bool alloc_full_path = false;
|
||||
if (argv[1][0] == '/')
|
||||
file_path = argv[1];
|
||||
else
|
||||
{file_path = get_target_filepath(argv[1], &path_len);alloc_full_path=true;}
|
||||
{
|
||||
file_path = get_target_filepath(argv[1], &path_len);
|
||||
alloc_full_path = true;
|
||||
}
|
||||
|
||||
// 打开文件
|
||||
int fd = open(file_path, O_CREAT);
|
||||
@ -351,7 +355,7 @@ int shell_cmd_touch(int argc, char **argv)
|
||||
close(fd);
|
||||
if (argv != NULL)
|
||||
free(argv);
|
||||
if(alloc_full_path)
|
||||
if (alloc_full_path)
|
||||
free(file_path);
|
||||
return 0;
|
||||
}
|
||||
@ -425,7 +429,7 @@ int shell_cmd_rmdir(int argc, char **argv)
|
||||
*/
|
||||
int shell_cmd_rm(int argc, char **argv)
|
||||
{
|
||||
char *full_path = NULL;
|
||||
char *full_path = NULL;
|
||||
int result_path_len = -1;
|
||||
int retval = 0;
|
||||
bool alloc_full_path = false;
|
||||
@ -472,7 +476,7 @@ int shell_cmd_exec(int argc, char **argv)
|
||||
execv(file_path, argv);
|
||||
free(argv);
|
||||
free(file_path);
|
||||
|
||||
|
||||
exit(-1);
|
||||
}
|
||||
else
|
||||
@ -498,7 +502,24 @@ int shell_cmd_about(int argc, char **argv)
|
||||
|
||||
parse_command(input_buffer, &aac, &aav);
|
||||
|
||||
shell_cmd_exec(aac, aav);
|
||||
return shell_cmd_exec(aac, aav);
|
||||
}
|
||||
|
||||
int shell_cmd_kill(int argc, char **argv)
|
||||
{
|
||||
int retval = 0;
|
||||
if (argc < 2)
|
||||
{
|
||||
printf("Usage: Kill <pid>\n");
|
||||
retval = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
printf("argc = %d, argv[1]=%s\n", argc, argv[1]);
|
||||
printf("atoi(argv[1])=%d\n", atoi(argv[1]));
|
||||
retval = syscall_invoke(SYS_KILL, atoi(argv[1]), SIGKILL, 0, 0, 0, 0, 0, 0);
|
||||
out:;
|
||||
free(argv);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -149,4 +149,6 @@ int shell_cmd_free(int argc, char **argv);
|
||||
* @param argv 返回值:参数列表
|
||||
* @return int
|
||||
*/
|
||||
int parse_command(char *buf, int *argc, char ***argv);
|
||||
int parse_command(char *buf, int *argc, char ***argv);
|
||||
|
||||
int shell_cmd_kill(int argc, char **argv);
|
Reference in New Issue
Block a user