Unix/Linux: Handler of SIGCONT/SIGTSTP

蓝咒 提交于 2019-12-11 17:40:22

问题


I'm currently writting program using signals, and I've got this trouble:

How can I change state of executing program to stopped/running without sending SIGSTOP/SIGCONT?

I understand, that I need to use:

 void add_to_runqueue (struct task_struct * p)

and

void del_from_runqueue (struct task_struct * p)

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).

Thanks in advance!


回答1:


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.

When you have a programs process ID (i.e. its number), you can use

kill(pid, SIGSTOP);

and

kill(pid, SIGCONT);

You should not use SIGTSTP unless you know what you are doing.



来源:https://stackoverflow.com/questions/6262701/unix-linux-handler-of-sigcont-sigtstp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!