Search code examples
clinuxsignals

Allow a process to stop another process for a given time c


I want to know if there is a way to make a parent process stop his child for a given time using signal
for example:

pid_t pid = fork();

if(pid==0){
  while(1){

//some code here

  }
}else{

// some code to make child process stop for x seconds

}

Solution

  • You may use SIGSTOP and SIGCONT to stop and continue the process. In combination with some time delay function (e.g. sleep() ) you may get the desired effect.

    You may check the example here: https://ostechnix.com/suspend-process-resume-later-linux/