mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   Linux (https://www.mersenneforum.org/forumdisplay.php?f=39)
-   -   How to pause/resume a process (https://www.mersenneforum.org/showthread.php?t=23284)

Prime95 2018-04-23 21:32

How to pause/resume a process
 
Since forever I've used "kill -stop <pid>" and "kill -cont <pid>" to pause mprime, run a benchmark, and resume mprime.

However, I've started using the screen command to launch mprime and now the stop command (sometimes) stops mprime as if one typed ^Z from the screen. The continue command has no effect. Instead I must do "screen -r" and "fg".

Am I doing something wrong? Is there a new preferred way to stop and resume processes?

Xyzzy 2018-04-23 21:48

To stop it, you could go to the screen that mprime is on and type CTRL+C, right?

Or are you trying to do it without reattaching your screen?

Prime95 2018-04-23 22:53

[QUOTE=Xyzzy;486034]Or are you trying to do it without reattaching your screen?[/QUOTE]

Yes.

I actually first noticed the problem when I was not using screen. I had booted the computer and started mprime at the main terminal. When I accessed the PC using ssh, "kill -stop" did the equivalent of a ^Z forcing me to physically visit the main terminal again.

What I'm looking for is a universal way to pause/resume. When I use the shared Knight's Landing machine (or some other shared machine) I do not want to accidentally step on someone's toes.

chalsall 2018-04-23 23:11

[QUOTE=Prime95;486038]When I accessed the PC using ssh, "kill -stop" did the equivalent of a ^Z forcing me to physically visit the main terminal again.[/QUOTE]

"kill -stop [PID]" is the exact same as ^Z. "kill -cont [PID]" [I]should[/I] be equivalent to "bg" in the console "owning" the mprime process.

Are you absolutely certain you've got the PID correct? If you're only running one instance of mprime, you might consider using the "killall" command. This would be safe in a multi-user situation so long as the command isn't run as root.

Xyzzy 2018-04-23 23:35

A weird (?) workaround would be to create a hook in mprime to look for a special file in the working directory. If the file exists, pause. Check at X second intervals. If file is removed, resume.

Sort of like "PauseWhileRunning".

This would be super easy to implement and might even be useful for other needs.

Prime95 2018-04-24 02:22

[QUOTE=chalsall;486040]"kill -stop [PID]" is the exact same as ^Z. "kill -cont [PID]" [I]should[/I] be equivalent to "bg" in the console "owning" the mprime process.

Are you absolutely certain you've got the PID correct? [/QUOTE]

The pid is correct, the problem is repeatable, "kill -stop" equals ^Z, "kill -cont" is the equals a no-op. All results verified by watching the CPU time as returned by "ps ax | grep mprime".

chalsall 2018-04-24 02:33

[QUOTE=Prime95;486056]The pid is correct, the problem is repeatable...[/QUOTE]

Is this only under screen? And a shot-in-the-dark, but killall's signals are case-sensitive (read: "-STOP" works, while "-stop" doesn't). Perhaps try "-CONT".

Mark Rose 2018-04-25 12:51

I run mprime in screen, and when I run `kill -stop PID` and then `kill -cont PID` it works as expected. This is under Ubuntu 16.04, and running as the same user.

aurashift 2018-06-18 18:07

dunno if this is helpful but I run './mprime &" then 'disown' and log out. if i need to restart it i just kill the process and relaunch it. I'm a linux amateur though so i dunno if there's a better way to do it.


All times are UTC. The time now is 08:34.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.