* Re: [gentoo-user] HOWTO: Freezing/unfreezing (groups of) processes
@ 2021-02-05 12:12 99% ` Ramon Fischer
0 siblings, 0 replies; 1+ results
From: Ramon Fischer @ 2021-02-05 12:12 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1.1: Type: text/plain, Size: 5054 bytes --]
Awesome stuff!
It might be unrelated, but I would like to mention a script[1] here,
which I have written in Bash to analyse process signals. It is called
"psig", which mimics some of the behaviour of Solaris' "psig" binary:
$ psig 23024
PID: 23024
Name: chrome
Queued: 0/63858
Signals caught:
---------------
Signal 17: SIGCHLD
Signal 15: SIGTERM
Signal 2: SIGINT
Signal 1: SIGHUP
Hexadecimal: 0 0 0 0 0 0 0 1 8
0 0 1 4 0 0 3
Binary: 0000 0000 0000 0000 0000 0000 0000 0001 1000
0000 0000 0001 0100 0000 0000 0011
Signals pending (process):
--------------------------
No signals found.
Signals pending (thread):
-------------------------
No signals found.
Signals blocked:
----------------
No signals found.
Signals ignored:
----------------
Signal 13: SIGPIPE
Hexadecimal: 0 0 0 0 0 0 0 0 0
0 0 0 1 0 0 0
Binary: 0000 0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0001 0000 0000 0000
-Ramon
[1] https://github.com/keks24/psig
On 05/02/2021 08:45, Walter Dnes wrote:
> Thanks for all the help over the years fellow Gentoo'ers. Maybe I can
> return the favour. So you've got a bunch of programs like Gnumeric or
> QEMU or Pale Moon ( or Firefox or Chrome or Opera ) sessions open, that
> are chewing up cpu and ram. You need those resouces for another
> program, but you don't want to shut those programs down and lose your
> place. If the programs could be frozen, cpu usage would go away, and
> memory could be swapped out. Here's a real-life example subset of a
> "ps -ef" output on my system. Replace "palemoon" with "firefox" or
> "chrome" or whatever browser you're using.
>
> waltdnes 4025 3173 0 Jan20 ? 01:54:21 /home/waltdnes/pm/palemoon/palemoon -new-instance -p palemoon
> waltdnes 7580 3173 4 Jan21 ? 17:45:11 /home/waltdnes/pm/palemoon/palemoon -new-instance -p dslr
> waltdnes 9813 3173 4 Jan21 ? 16:24:23 /home/waltdnes/pm/palemoon/palemoon -new-instance -p wxforum
> waltdnes 22455 3173 58 01:31 ? 00:08:29 /home/waltdnes/pm/palemoon/palemoon -new-instance -p slashdot
> waltdnes 22523 3173 0 01:31 ? 00:00:05 /home/waltdnes/pm/palemoon/palemoon -new-instance -p youtube
> waltdnes 22660 3173 12 01:45 ? 00:00:04 /usr/bin/gnumeric /home/waltdnes/worldtemps/temperatures/temperatures.gnumeric
> waltdnes 20346 20345 4 Jan28 ? 08:10:50 /usr/bin/qemu-system-x86_64 -enable-kvm -runas waltdnes -cpu host -monitor vc -display gtk -drive file=arcac.img,format=raw -netdev user,id=mynetwork -device e1000,netdev=mynetwork -rtc base=localtime,clock=host -m 1024 -name ArcaOS VM -vga std -parallel none
>
> You might want to RTFM on the "kill" command if you're skeptical. It
> does a lot more than kill programs. "kill -L" will give you a nicely
> formatted list of available signals. For this discussion we're
> interested in just "SIGCONT" and "SIGSTOP" ( *NOT* "SIGSTP" ). If I
> want to freeze the Slashdot session, I can run "kill -SIGSTOP 22455". To
> unfreeze it, I can run "kill -SIGCONT 22455". You can "SIGSTOP" on a
> pid multiple times consecutively without problems; ditto for "SIGCONT".
>
> So far, so good, but running "ps -ef | grep whatever" and then
> typing the kill -SIGSTOP/SIGCONT command on the correct pid is grunt
> work, subject to typos. I've set up a couple of scripts in ~/bin to
> stop/continue processes, or groups thereof. The following scripts do a
> "dumb grep" of "ps -ef" output, redirecting to /dev/shm/temp.txt. That
> file is then read, and the second element of each line is the pid, which
> is fed to the "kill" command. I store the scripts as ~/bin/pstop and
> ~/bin/pcont.
>
> ================== pstop (process stop) script ==================
> #!/bin/bash
> ps -ef | grep ${1} | grep -v "grep ${1}" | grep -v pstop > /dev/shm/temp.txt
> while read
> do
> inputarray=(${REPLY})
> kill -SIGSTOP ${inputarray[1]}
> done < /dev/shm/temp.txt
>
> ================ pcont (process continue) script ================
> #!/bin/bash
> ps -ef | grep ${1} | grep -v "grep ${1}" | grep -v pcont > /dev/shm/temp.txt
> while read
> do
> inputarray=(${REPLY})
> kill -SIGCONT ${inputarray[1]}
> done < /dev/shm/temp.txt
>
> =================================================================
>
> To stop all Pale Moon instances, execute "pstop palemoon". To stop
> only the Slashdot session, run "pstop slashdot". Ditto for the pcont
> command. I hope people find this useful.
>
--
GPG public key: 5983 98DA 5F4D A464 38FD CF87 155B E264 13E6 99BF
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]
^ permalink raw reply [relevance 99%]
Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-02-05 7:45 [gentoo-user] HOWTO: Freezing/unfreezing (groups of) processes Walter Dnes
2021-02-05 12:12 99% ` Ramon Fischer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox