You are not logged in.

#1 2012-06-03 15:08:36

peoro
Member
Registered: 2007-06-10
Posts: 67

System hanging on shutdown

The home directories on my system are on NFS.
Most of the times, when users log out of their graphical session, some of their processes keep running (for instance /usr/bin/nepomukserver for KDE users and some processes related to pulse or to chromium).

When shutting down the system, arch scripts first try unmounting network filesystems, and this fails, since /home is busy; then they send a SIGTERM to processes, and this fails as well (I believe it's because the network has been halted but /home hasn't been mounted), then the system hangs while unmounting non-API filesystems.
If, before shutting down, I manually kill the user processes (nepomukserver, pulse, chromium, ...), arch is able to shutdown as expected.

Am I the only one affected by this problem?
How am I supposed to solve it?
I'm thinking about writing a script to terminate (`kill` and then `kill -9`) any process using /home (`lsof /home`), but this looks like a terrible hack...

Offline

#2 2012-06-13 11:22:38

peoro
Member
Registered: 2007-06-10
Posts: 67

Re: System hanging on shutdown

So, since I couldn't find any other solution, decided to write a script (an init script to add to the DAEMONS array) that kills the processes using /home while halting the machine...

If anybody will ever need it, here it is:

/etc/rc.d/pathliberator

#!/bin/bash

# Path Liberator
# kills processes that are using a given path

DAEMON=pathliberator

. /etc/rc.conf
. /etc/rc.d/functions
[ -r /etc/conf.d/$DAEMON ] && . /etc/conf.d/$DAEMON

case "$1" in
        start)
                stat_busy "Starting path liberator"
                add_daemon $DAEMON
                stat_done
                ;;
        stop)
                success=true
                for path in ${PATHS_TO_LIBERATE[@]}
                do
                        pids=$( lsof -Fp $path | sed -rs "s/^.(.*)$/\1/g" )
                        if [ "$pids" == "" ]
                        then
                                status "$path was already free" true
                                continue
                        fi

                        # kill -TERM
                        stat_busy "Liberating $path"
                        kill -15 ${pids[@]} &>/dev/null
                        pids=$( lsof -Fp $path | sed -rs "s/^.(.*)$/\1/g" )
                        if [ "$pids" == "" ]; then
                                stat_done
                                continue
                        fi
                        stat_fail

                        pids=$( lsof -Fp $path | sed -rs "s/^.(.*)$/\1/g" )
                        # kill -KILL
                        stat_busy "Liberating $path with SIGKILL"
                        kill -9 ${pids[@]} &>/dev/null
                        pids=$( lsof -Fp $path | sed -rs "s/^.(.*)$/\1/g" )
                        if [ "$pids" == "" ]; then
                                stat_done
                                continue
                        fi
                        stat_fail
                        success=false
                done

                status "Paths liberated" $success
                if [ $success ]
                then
                        rm_daemon $DAEMON
                fi
                ;;
        restart)
                $0 stop
                $0 start
                ;;
                *)
        echo "usage: $0 {start|stop|restart}"
esac
exit 0

/etc/conf.d/pathliberator

#
# Parameters to be passed to pathliberator
#

PATHS_TO_LIBERATE=(/home/)

It seems to be working, although didn't deeply test it...

My DAEMONS array now looks like this:
DAEMONS=(hwclock syslog-ng cpufreq network crond nscd dbus rpcbind nfs-common netfs pathliberator gpm sshd @ntpdate alsa fuse gdm avahi-daemon)

Last edited by peoro (2012-06-13 11:23:17)

Offline

#3 2012-06-13 22:03:51

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,132

Re: System hanging on shutdown

I thought that using hwclock with ntp was problematic? I mention this partly because another thread about what maybe a similar issue includes comments from people who are also experiencing clock issues.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#4 2012-06-14 20:53:19

peoro
Member
Registered: 2007-06-10
Posts: 67

Re: System hanging on shutdown

Uh, thank you for pointing that out, fixed my DAEMONS array.
Anyway that didn't have much to do with the problem I was having at shutdown.

Offline

#5 2012-06-14 21:20:02

Zancarius
Member
From: NM, USA
Registered: 2012-05-06
Posts: 207

Re: System hanging on shutdown

cfr wrote:

I thought that using hwclock with ntp was problematic? I mention this partly because another thread about what maybe a similar issue includes comments from people who are also experiencing clock issues.


Interesting... thank you, cfr.

I had mistakenly assumed that I had fixed my hwclock configs once upon a time (many months ago) and since forgot about it. I just checked my DAEMONs array and hwclock is most definitely not present but ntpd is. I don't remember ever changing that.

Now you have me worried that I'm losing my mind. Did I read something in the Wiki about not running hwclock and ntpd only to forget what I read? Is this early onset Alzheimer's?


He who has no .plan has small finger.
~Confucius on UNIX.

Offline

#6 2012-07-06 12:25:19

lotan_rm
Member
Registered: 2012-05-09
Posts: 3

Re: System hanging on shutdown

Thank you very much, peoro, you've helped me very much. I needed exactly that.

Offline

Board footer

Powered by FluxBB