mersenneforum.org  

Go Back   mersenneforum.org > Extra Stuff > Linux

Reply
 
Thread Tools
Old 2018-04-23, 21:32   #1
Prime95
P90 years forever!
 
Prime95's Avatar
 
Aug 2002
Yeehaw, FL

2×53×71 Posts
Default 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?

Last fiddled with by Prime95 on 2018-04-23 at 21:33
Prime95 is offline   Reply With Quote
Old 2018-04-23, 21:48   #2
Xyzzy
 
Xyzzy's Avatar
 
"Mike"
Aug 2002

25·257 Posts
Default

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?
Xyzzy is offline   Reply With Quote
Old 2018-04-23, 22:53   #3
Prime95
P90 years forever!
 
Prime95's Avatar
 
Aug 2002
Yeehaw, FL

165468 Posts
Default

Quote:
Originally Posted by Xyzzy View Post
Or are you trying to do it without reattaching your screen?
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.

Last fiddled with by Prime95 on 2018-04-23 at 22:54
Prime95 is offline   Reply With Quote
Old 2018-04-23, 23:11   #4
chalsall
If I May
 
chalsall's Avatar
 
"Chris Halsall"
Sep 2002
Barbados

260316 Posts
Default

Quote:
Originally Posted by Prime95 View Post
When I accessed the PC using ssh, "kill -stop" did the equivalent of a ^Z forcing me to physically visit the main terminal again.
"kill -stop [PID]" is the exact same as ^Z. "kill -cont [PID]" should 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.
chalsall is offline   Reply With Quote
Old 2018-04-23, 23:35   #5
Xyzzy
 
Xyzzy's Avatar
 
"Mike"
Aug 2002

25·257 Posts
Default

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.
Xyzzy is offline   Reply With Quote
Old 2018-04-24, 02:22   #6
Prime95
P90 years forever!
 
Prime95's Avatar
 
Aug 2002
Yeehaw, FL

2·53·71 Posts
Default

Quote:
Originally Posted by chalsall View Post
"kill -stop [PID]" is the exact same as ^Z. "kill -cont [PID]" should be equivalent to "bg" in the console "owning" the mprime process.

Are you absolutely certain you've got the PID correct?
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".
Prime95 is offline   Reply With Quote
Old 2018-04-24, 02:33   #7
chalsall
If I May
 
chalsall's Avatar
 
"Chris Halsall"
Sep 2002
Barbados

230038 Posts
Default

Quote:
Originally Posted by Prime95 View Post
The pid is correct, the problem is repeatable...
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".
chalsall is offline   Reply With Quote
Old 2018-04-25, 12:51   #8
Mark Rose
 
Mark Rose's Avatar
 
"/X\(‘-‘)/X\"
Jan 2013

B7416 Posts
Default

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.
Mark Rose is offline   Reply With Quote
Old 2018-06-18, 18:07   #9
aurashift
 
Jan 2015

3758 Posts
Default

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.

Last fiddled with by aurashift on 2018-06-18 at 18:07
aurashift is offline   Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Resume linear algebra Timic Msieve 35 2020-10-05 23:08
Resume dependency processing? sean YAFU 7 2017-10-14 02:30
Question about save & resume frmky GMP-ECM 7 2012-08-02 08:22
Question about resume Phinne Operation Billion Digits 2 2009-04-25 10:00
To code a "pause and save" function in GMP initial Programming 3 2007-09-26 21:34

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


Sat Jul 17 08:34:44 UTC 2021 up 50 days, 6:21, 1 user, load averages: 1.05, 1.40, 1.47

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

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.