Unix/Linux:SIGCONT/SIGTSTP的处理程序 [英] Unix/Linux: Handler of SIGCONT/SIGTSTP
问题描述
我目前正在使用信号编写程序,但遇到了这个麻烦:
I'm currently writting program using signals, and I've got this trouble:
如何在不发送SIGSTOP
/SIGCONT
的情况下将执行程序的状态更改为已停止/正在运行?
How can I change state of executing program to stopped/running without sending SIGSTOP
/SIGCONT
?
我了解,我需要使用:
void add_to_runqueue (struct task_struct * p)
和
void del_from_runqueue (struct task_struct * p)
但是如何获取当前正在运行的进程的结构task_struct?
but how to obtain structure task_struct of currently running process?
还:如果这就是我要做的全部事情(调用这两个函数).
Also: if it is all that I need to do (calling those 2 functions).
提前谢谢!
推荐答案
这些功能将是内核功能,即操作系统内部的功能.在编写程序时,需要进行相应的系统调用,具体情况为kill
.
These functions would be kernel functions, i.e. internal to the OS. When you are writing a program, you need to go through the appropriate system calls, in your case kill
.
拥有程序进程ID(即其编号)时,您可以使用
When you have a programs process ID (i.e. its number), you can use
kill(pid, SIGSTOP);
和
kill(pid, SIGCONT);
除非您知道自己在做什么,否则不应该使用SIGTSTP
.
You should not use SIGTSTP
unless you know what you are doing.
这篇关于Unix/Linux:SIGCONT/SIGTSTP的处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!