Karol
Karol

Reputation: 11

Unix/Linux: Handler of SIGCONT/SIGTSTP

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!

Upvotes: 1

Views: 5449

Answers (1)

Simon Richter
Simon Richter

Reputation: 29586

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.

Upvotes: 2

Related Questions