Solved Suspend (pause) - resume (continue) entire process

Is there a programmatic / cli way of completely suspending or pausing or freezing (or less desirable: dumping or checkpointing) a running process (e.g. by PID) and later resuming (restoring) it to continue to run from where it left of? My reasoning is that OS routinely performs "such preempting" so there has to be a way for me to do the same?

To be specific: process would typically use multiple threads, perform heavy disk IO (and would need to continue to write to those files on resume), use several G of RAM (that's why I'd rather avoid dumping), does not communicate over network. Machine is dedicated to a single task and under my complete control so perfectly fine to do in-kernel, root privilege etc. Disk IO is either to dedicated ZFS pool or separate UFS drives in case it helps.

I'm perfectly ok with just "pausing" a process especially any IO rather than just dumping its state to persistent storage.

Thank you
 
Is there a programmatic / cli way of completely suspending or pausing or freezing (or less desirable: dumping or checkpointing) a running process (e.g. by PID) and later resuming (restoring) it to continue to run from where it left of?
Hit CTRL-Z, that will 'suspend' the running process. It will continue where it left off with fg.
 
renice()?
renice man page said:
The super-user may alter the priority of any process and set the
priority to any value in the range PRIO_MIN (-20) to PRIO_MAX. Useful
priorities are: 20 (the affected processes will run only when nothing
else in the system wants to
), 0 (the ``base'' scheduling priority),
anything negative (to make things go very fast).
If I understand this correctly, this might be used to put a process to near-sleep effectively, by making sure some other thing runs.
 
Hit CTRL-Z, that will 'suspend' the running process. It will continue where it left off with fg.
Need to do it programmatically e.g. from a script. I thought maybe there was a signal I could send. E.g. IIRC linux offers kill -TSTP and then kill -CONT. I don't see anything similar in FreeBSD kill(1)(). Also even if it did, does the underlying program need to "respect" aka "be pre-programmed to gracefully handle" such signals?
 
renice()?

If I understand this correctly, this might be used to put a process to near-sleep effectively, by making sure some other thing runs.
ah, I remember seeing this nice value in htop. Thank you. Man is quiet re how soon this takes effect. Anyone knows if its pretty much instantaneous? Does process yield to OS or OS preempts it so it doesn't occupy resources? Perhaps someone with a bit of under the hood knowledge could brief exactly what effects renicing triggers in the system, please?
 
I always believed that this is done by the scheduler, i.e. preemptively.
So I guess priority should be instantly changed.

BTW, the manpage says this can not only be applied to PIDs, but also to userids.
Maybe this is easier than finding out and using PIDS?

manpage said:
The renice utility alters the scheduling priority of one or more running
processes. The following who parameters are interpreted as process ID's,
process group ID's, user ID's or user names. The renice'ing of a process
group causes all processes in the process group to have their scheduling
priority altered. The renice'ing of a user causes all processes owned by
the user to have their scheduling priority altered.
By default, the
processes to be affected are specified by their process ID's.
 
E.g. IIRC linux offers kill -TSTP and then kill -CONT. I don't see anything similar in FreeBSD kill(1).
signal(3):
Code:
     17    SIGSTOP          stop process         stop (cannot be caught or
                                                 ignored)
     18    SIGTSTP          stop process         stop signal generated from
                                                 keyboard
     19    SIGCONT          discard signal       continue after stop
CTRL-Z actually sends a SIGTSTP to the process.
 
renice()?

If I understand this correctly, this might be used to put a process to near-sleep effectively, by making sure some other thing runs.
no idea what it's supposed to achieve. I just reniced process to nice +20 and it had no discernible effect on its performance.

*EDIT* could it be that it had no effect cause I have plenty of availabel cores on that machine?
 
Back
Top