An assortment of indigestible things

Category: Uncategorized

ksh deliberately segfaults if the last command in a script crashes

I recently found that ksh will deliberately crash if the last command in a script crashes. Other shells just set the appropriate exit code, but ksh sends itself the same signal that its child received. This can confuse the unwary (i.e. me) when trying to track down what crashed with abrt logs.

Getting rid of automounts that won’t go away

If you delete an automount from a map and restart the daemon, the mountpoint should go away… but sometimes it doesn’t, and you end up with this:

drwxr-xr-x 2 root root 0 Oct 22 11:24 /wibble

The size of zero indicates that the system still sees a mountpoint here, and in /proc/mounts you’ll see something like

/etc/auto.mymap /wibble autofs rw,relatime,fd=5,pgrp=31311,timeout=86400,minproto=5,maxproto=5,direct 0 0

So the mountpoint is both there and not there, and any attempt to access it will hang. Trying to unmount it manually doesn’t work either. This can cause merry hell: on a default system, the updatedb process that locate uses will hang forever when it reaches the mountpoint (even though it’s configured to ignore nfs and autofs), and the rest of cron.daily will never be reached, so no log rotation for you. After a few days you’ll see lots of find processes cluttering up the place.

A reboot will fix it of course, but there is a much simpler and less destructive way:

umount -l /wibble

The ‘-l’ option is described in the manpage as

Lazy unmount. Detach the filesystem from the filesystem hierarchy now, and cleanup all references to the filesystem as soon as it is not busy anymore. (Requires kernel 2.4.11 or later.)

That suggests a reboot might be warranted at some point to make sure it’s completely gone away, but it certainly does the trick. The entry in /proc/mounts disappears, and the directory now looks like

drwxr-xr-x 7 root root 4096 Oct 22 11:40 /wibble

A much healthier-looking directory, which you can now safely delete. Don’t forget to kill all those backlogged jobs too.


I’ve been toying for a while with the idea of publishing any useful little tidbits of information I come across, so if I can be arsed, this is where they’ll appear.

Of course, far more likely is that I’ll forget about this blog and it’ll go the same way as my last attempt at blogging (c2003, can’t even remember the URL)…

Powered by WordPress & Theme by Anders Norén