What to restart after a system upgrade ?

If you're familiar with Windows, you know rebooting is something pretty common. You're usually asked to reboot after a system upgrade, after (or in order to) installing a new application, after removing one...

And one of the thing you hear about Linux, is that you almost never need to reboot. Unless you install a new kernel, rebooting is not necessary, but that doesn't mean you don't have to restart a few things.

It was actually one question I had early on after moving to Linux : how to know what to restart after a system upgrade ?

Some things are pretty obvious: if you upgraded Firefox to a new version, you'll have to restart it.

Similarly, having upgraded the X server, it needs to be restarted. I'm not exactly sure how that works when one uses a Display Manager, but as it turns out I don't (I use the great xlsh to log in, and auto-start my X session through .bash_profile), so when I need to restart X, I just log out and back in.

But things gets a bit more complicated when it comes to libraries. Because it's not always obvious which application uses a given library, even when you know what said library does.

A little trick I found recently that can help with that, is using lsof. It's a great tool that can list all opened files, and of course that also includes deleted files.

So, one can easily use it and grep the list of all opened files whose name contains "lib" - as is often if not always the case for libraries - and then we get the list of applications that are still using old/deleted versions of one or more libraries. Or, of applications that should be restarted.

Now because I'm curious I guess, I like to know why a given app needs to be restarted, so I tweaked it a bit, so that it not only gives the application to restart; but also the name of the deleted library it uses :

lsof +c 0 | grep 'DEL.*lib' | awk '1 { print $1 ": " $NF }' | sort -u

Automaticly check for deleted libraries in use after a sysupgrade

As you might know, I do my system upgrades through kalu & its system updater. And one thing it allows you to do, is define some process to be ran after each sysupgrade.

Now because this is all done from a GUI, I wanted this to also be done through a GUI and not by opening a terminal. So here's the little script I made :

  1. #!/bin/bash
  2. ret=2
  3. while [ $ret -eq 2 ]; do
  4.     LIST=$(lsof +c 0 | grep 'DEL.*lib' | awk '1 { print $1 ": " $NF }' | sort -u)
  5.     if [[ $LIST = "" ]]; then
  6.         ic-info 'No deleted libraries in use found'
  7.         exit 0
  8.     fi
  9.     echo "$LIST" | ic-text -e Refresh -E gtk-refresh -T 'Deleted Libraries In Use'
  10.     ret=$?
  11. done

This makes use of intercourse to provide GUI elements, but of course you could use anything else, e.g. zenity.

Restarting XFCE panel ?

As I mentionned earlier, I don't use a Display Manager, and upon login a new X session is automatically started via my .bash_profile

One more thing I don't use, is a session manager, not XFCE's own or any other. As far as I can tell, what this would do besides eat ressources is make note of running applications when I log out, to start them back when I log in. Definately not something I have any interest in.

Something else it would do, is get me buttons to restart or shutdown the computer. But I don't care for that, since I can do it from my xlsh shell.

But as a result, when I want to close th XFCE panel, I get a little warning : You have started X without session manager. Clicking Quit will close the X server.

This is a bit unfortunate, because it means that I can't restart the panel without closing X, any running X apps while at it, and logging me out. Of course, there's a way around this.

xfce-utils comes with a xinitrc that already takes care of panel crash. In such an event, you get a little message (using xmessage) about it, and the panel is restarted. So I just edited my ~/.config/xfce4/xinitrc to have the ability to either log out, or simply restart the panel, e.g. so it can use a newly-upgraded library.

  1. while true; do
  2.         if test $ret -ne 0; then
  3.                 ic-error -T Error 'A crash occured in the panel' -D <<EOF
  4. Please report this to the xfce4-dev@xfce.org list
  5. or on http://bugs.xfce.org
  6. Meanwhile the panel will be restarted
  7. EOF
  8.                 cat >&2 <<EOF
  9. A crash occured in the panel
  10. Please report this to the xfce4-dev@xfce.org list
  11. or on http://bugs.xfce.org
  12. Meanwhile the panel will be restarted
  13. EOF
  14.         else
  15.                 # 3 = closed w/out button; 1 = Restart; 0 = Close & log out
  16.                 ic-question -T 'Logging out?' \
  17.                 -b 'Close X and log out' -i gtk-quit \
  18.                 -B 'Restart panel' -I gtk-refresh \
  19.                 'Do you want to close X & log out ?' \
  20.                 -d 'Closing X will terminate all running programs. Better to close them properly first.'
  21.                 if test $? -eq 0; then
  22.                         break
  23.                 fi
  24.         fi
  25.         $panel
  26.         ret=$?
  27. done

Top of Page