I am trying to solve the problem given in pause youtube-dl when network is disconnected and resume when it is connected again
To stop and resume process, I have taken guideline from How to suspend and resume processes
The problem is, the following works:
processid=$(pgrep youtube-dl)
kill -TSTP $processid
When I run the above script, The terminal running youtube-dl shows:
zsh: suspended youtube-dl
% jobs
[1] + suspended youtube-dl
I have to go to the terminal and type the following command to continue the process:
% fg %1
[1] + continued youtube-dl
How to resume processes from a script instead of going to the terminal and typing a command?
Just for the sake of being thorough, If I run tail -f ~/.xsession-errors, I can pause it from the script using kill -TSTP $processid and resume it using kill -CONT $processid. It does not invoke the job control.