I would like to pause this build process , shutdown my laptop and sleep for a while and resume later.Now I've found a linux command 'fg' that could work for me. But i'm not sure of how it's used and whether it will work in my case( i want to pause 'make' and shutdown my system).
Thanks in advance
You can pause execution of a process by sending it a SIGSTOP signal and then later resume it by sending it a SIGCONT .
First, find the pid of the running process using ps command. Then, pause it using kill -STOP <PID> , and then hibernate your system. Resume your system and resume the stopped process using command kill -CONT <PID> .
Use ctrl -S for halting display, and ctrl -Q for resuming. You don't need to modify your Makefile.
The SIGSTOP and SIGCONT signals suspend and resume a process, respectively.
First of all, makefiles are intended, almost, to do what you want: they should build only the missing or not up-to-date parts of a project. So, if you have a project made by 100 files, and start the build process, and after compilation of 50 files the build gets interrupted, on the next build invocation the process should restart, more or less, from where it was interrupted. This happens if the makefile is written well, and nobody issues a "make clean", of course.
Then you talk about the fg command, but its purpose is different from what you want: if you shutdown your computer, all the programs get stopped (and will not restart automatically). May be you can hibernate your laptop and, if yes, you don't need any further precautions.
Assuming you want to send a SIGINT
to interrupt the process, the short answer is it depends on the process. For example, it's totally possible to stop an rsync
process then resume it later. In order to stop a process then continue where you left off, you'd need a mechanism to store the last state the process was in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With