LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


View Poll Results: I use
xscreensaver 41 89.13%
xlockmore 5 10.87%
Voters: 46. You may not vote on this poll

Reply
  Search this Thread
Old 04-07-2020, 02:45 PM   #46
FlinchX
Member
 
Registered: Nov 2017
Distribution: Slackware Linux
Posts: 496

Rep: Reputation: Disabled

Quote:
Originally Posted by ttk View Post
Yes, that's most of it. My laptop draws less power and generates less heat. Heat was less of an issue with my T530, but this new P73 runs a lot hotter, even with the CPU speed throttled.

Also, SIGSTOP'ing the browser helps stave off memory leaks. Pale Moon is a lot better about not leaking memory than Firefox, but it still happens a bit.

It makes locking my system a sort of half-way suspend, without the risks or overhead of suspend. All of the processes which would consume measurable CPU are denied CPU quanta by the kernel until SIGCONT is sent, so there's nothing going on.
This is very interesting, I've never seen something like this done before. So I have one more question. Why not SIGSTOP'ing most processes then, and only keep running those that are vital for making it possible to unlock the system later (frankly, I don't know which ones would those be)? Or is it too hard to figure in a script which processes to keep running and which ones to stop?
 
Old 04-07-2020, 05:04 PM   #47
ttk
Member
 
Registered: May 2012
Location: Sebastopol, CA
Distribution: Slackware64
Posts: 951
Blog Entries: 27

Rep: Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339
Quote:
Originally Posted by FlinchX View Post
This is very interesting, I've never seen something like this done before. So I have one more question. Why not SIGSTOP'ing most processes then, and only keep running those that are vital for making it possible to unlock the system later (frankly, I don't know which ones would those be)? Or is it too hard to figure in a script which processes to keep running and which ones to stop?
When a script evolves into anything more than a sequence of simple commands, I switch up to perl :-)

The perl for implementing this would be easy. The hard part would be working up a list of processes to not stop. Once that is incorporated into a regex ($keepers), sending SIGSTOP to everything else is a one-liner:
Code:
kill 19, (map {$_ =~ /^\w+\s+(\d+)/ ? $1 : ()} grep !/$keepers/, `ps auxww`);
Or split out into simple statements for readability and using a precompiled regex:
Code:
my @stopped;  # a list of pids we are stopping, for continuing later
for my $p (`ps auxww`) { # iterates over the output of command, assigning $p to each line of output
  next if ($p =~ $keepers);  # skip processes we need, like init and Xorg
  next if ($p !~ /^\w+\s+(\d+)/);  # extract the process id with a regex
  my $pid = $1;
  push @stopped, $pid;  # save pid for later
  kill 19, $pid;  # send SIGSTOP to the process
}
And then to issue SIGCONT to the stopped processes we can just pass the whole list to kill:
Code:
kill 18, @stopped;
The $keepers regex would be something like /(\[|$$|sshd|xlock|Xorg)/ .. I'd include sshd in case I needed to ssh into the laptop while it was locked. The "$$" is perl's builtin for referring to its own process, so adding $$ to the regex would prevent the script from stopping itself. The "\[" would match the kernel processes and init (which shows the runlevel in []'s).

To stop all processes, not just those owned by the user, the script would have to run as root. If it's not, though, then the kill statement would silently fail to issue SIGSTOP to other users' processes and no harm done.

I probably won't use this logic in xlament any time soon, because it's bumping into the point of diminishing returns. When I killall that scant handful of processes, the load average sinks to about 0.01, which is good enough :-) no need to add complexity beyond that.
Attached Thumbnails
Click image for larger version

Name:	loadavg.png
Views:	4
Size:	3.5 KB
ID:	32926  

Last edited by ttk; 04-07-2020 at 08:10 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] slackware-current: xlockmore-5.51 broken marrowsuck Slackware 6 07-20-2017 04:28 AM
Can we have a chance to get one day, back, xlockmore into the debian stable? frenchn00b Debian 0 06-13-2009 12:40 AM
Xlockmore on FreeBSD mobydick *BSD 0 12-23-2008 01:22 PM
xscreensaver installed, but no xscreensaver-demo command? dalesan Linux - Software 7 09-01-2004 01:06 PM
xlockmore locking up system php Slackware 2 06-26-2004 02:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 08:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration