允许一个进程在给定时间内停止另一个进程 c

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

我想知道是否有办法使用 signal
让父进程在给定时间内停止其子进程 例如:

pid_t pid = fork();

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

//some code here

  }
}else{

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

}

您可以使用 SIGSTOP 和 SIGCONT 来停止和继续进程。结合一些时间延迟函数(例如 sleep() )你可能会得到想要的效果。

您可以在此处查看示例:https://ostechnix.com/suspend-process-resume-later-linux/