I have a Linux kernel module that runs every 10 seconds and scans whether there are any resource-hogging processes. I then need to suspend them for a minute (i.e. six loops through the code) and let them run again afterwards. I have already written the code to check for the condition, and have all the appropriate task_struct pointers.
The question is, how do I suspend a task, given its task_struct pointer? And later on, how do I resume that task?
You could suspend the process by sending it
STOPsignal, then resume it by sending it aCONTsignal; perhaps viakill_pid(task_pid(task_struct), SIGSTOP, 1)andkill_pid(task_pid(task_struct), SIGCONT, 1)for example.That approach is not perfect. For example, another process can keep such a process running by sending it
CONTsignals, unless you also blockCONTsignals during the time-out period.