suspend


How to suspend Gnome Ubuntu 18.04LTS from top right menu

Recently, we were using the suspend option by searching option through the “Activities” menu. We were looking for alternatives for scenarios where we would not like to use a keyboard (e.g. on a touch-enabled screen).
After some quick testing we saw that when you long press the power button it turns into a Suspend button!!

In this video we can see that if you long press the power off button in the top right menu it will convert to the “Suspend” option!


How to “pause” (suspend) an active process

Recently, we were executing the following time-wasting application and we wanted to pause it somehow and release the CPU that was being used temporarily for other tasks.
Unfortunately, the process was not executing on an active console, so we could not press CTRL+Z and suspend it.
Conveniently, the kill command provides us with the suspend functionality as long as we know the PID of the process to be suspended.

Using ps x, we found the PID of the application even though it was not attached to an active console.

Then to suspend the application, we used

kill -TSTP "$PID";

which instructed the process to stop by sending it the SIGTSTP signal.

Fortunately, our application did not block the signal and it was suspended.

Note: In case an application ignores the SIGTSTP signal, you can still force it to suspend by sending it the SIGSTOP signal as follows

kill -STOP "$PID";

After we were done, we resumed the execution of the process by sending the SIGCONT signal to it

kill -CONT "$PID";