Many people are aware of the fact, that you kann kill a process. But you can suspend a running process in order to resume the execution later.
root@testbed:~# cat stopstart.pl
#!/usr/bin/perl
while () {
$zeit=time();
print "... $zeit \n";
sleep(2);
}The script just prints out unixtime every 2 seconds.
root@testbed:~# ./stopstart.pl
... 1746250121
... 1746250123
... 1746250125
... 1746250146
... 1746250148
... 1746250150 You surely have noticed, that there are missing timestamps between 1746250125 and 1746250146. What happened between those timestamps? In another shell i stopped the process.
root@testbed:~# ps -ef | grep "stopstart"
root 5140 5092 0 07:28:26 pts/1 0:00 /usr/bin/perl ./stopstart.pl
root@testbed:~# pstop 5140When you look at the flags of the process, you will see the flags indicating, that the process has stopped:
5140: /usr/bin/perl ./stopstart.pl
data model = _LP64 flags = MSACCT|MSFORK
/1: flags = STOPPED|ISTOP|ASLEEP nanosleep(0x7fc3a2c94760,0x7fc3a2c94770)
why = PR_REQUESTEDAfter waiting for a moment, i resumed the process. The perl script continued to print out the timestamps and the flags indicating a stopped process disappeared.
root@testbed:~# prun 5140
root@testbed:~# pflags 5140
5140: /usr/bin/perl ./stopstart.pl
data model = _LP64 flags = MSACCT|MSFORK
/1: flags = ASLEEP nanosleep(0x7fc3a2c94760,0x7fc3a2c94770)