Page 1 of 1

A little thought on Puppy's shutdown-scripts

Posted: Sat Feb 20, 2021 10:36 pm
by MHHP

In /sbin/poweroff and in /usr/bin/wmexit, at line 37 and 53, respectively (Slacko 7.0),
there is a test [ "$DISPLAY" ] that would yield a negative answer if I would have
X still running and just entered a real tty-console and issued the command
poweroff/reboot or wmpoweroff/wmreboot.

Those tests would possibly be safer in this use-case if [ -f /root/.XLOADED ] or, possibly,
some grep-construct like [ "$(ps|grep "X* :"|grep -v grep)" ] or [ "$(ps|grep "X.*:"|grep -v grep)" ]
were used.

Any thoughts? (Or have I missed something here?)

/MHHP


Re: A little thought on Puppy's shutdown-scripts

Posted: Sun Feb 21, 2021 8:09 pm
by williams2

Something like:

Code: Select all

X_IS_RUNNING="no"
ps|grep -q "[X]org \|[X] " && X_IS_RUNNING="yes"

should be "yes" if X or Xorg is running, or at least any process name ending with X or Xorg.

Edit: Or:

Code: Select all

pidof Xorg X >/dev/null && X_IS_RUNNING="yes"
# or maybe:
X_IS_RUNNING="$(pidof Xorg X)"

Assuming you want to shutdown safely when X is frozen or almost frozen, killing X explicitly first might work around the DISPLAY test.

Code: Select all

killall X Xorg
killall -9 X Xorg
reboot

Re: A little thought on Puppy's shutdown-scripts

Posted: Tue Feb 23, 2021 11:41 pm
by MHHP

Thanks, williams2!

I never really stated why I asked about this.
Up until Slacko-6.9.9.9 I could jump out to a tty-console (while X was
still running) and issue the command reboot/shutdown or wmreboot/wmshutdown
and have just that; a proper reboot/wmreboot or shutdown/wmshutdown.

In Slacko-7.0 I could not.

So I started looking around in the shutdown-scripts...

At first suspected the [ $DISPLAY ]-tests, which I had forgotten were
present in earlier, "working", versions of puppy.

After putting a lot of debug-messages (and sleeps, so I could read them)
into the scripts, I came to the conclusion that my computer needs a short
"sleep" inserted into /sbin/poweroff so as to restore functionality of
earlier puppys.

After this issue now has been solved, I will delve into my original question
of this thread; [ $DISPLAY ]-tests versus something (possibly) safer in
case of issuing "reboot/shutdown" from a tty-console with X still running.

Cheers
/MHHP

Code: Select all

--- ./slacko-7.0/sbin/poweroff	2020-12-19 22:10:09.000000000 +0100
+++ ./MHHP/sbin/poweroff	2021-02-23 23:54:05.000000000 +0100
@@ -26,6 +26,11 @@
  can_shutdown=0
 fi
 
+# MHHP: I really need a short sleep here, otherwise my computer gets 
+#       stuck after the wmreboot command...
+sleep 0.5
+# /MHHP
+
 . /etc/rc.d/PUPSTATE
 
 if [ "$PUPMODE" = "5" ] && [ $PPID -eq 1 ] ; then

[\code]