the latest

The Big Sleep

Here's the thing: Mac OS X is great . . . usually. But if you've ever been connected to a network share and put your laptop to sleep and then had the audacity to wake it up on a different network - whoa boy! You can expect nothing less than a five minute, spinning beach ball of death, Finder freeze-up. For reasons unknown, OS X decides to freak out and hang if it can't find a network share. I've written a short, dramatic piece illustrating what I'm talking about.

Location: a dimly lit office at night.

Tyler enters the room carrying his MacBook Pro under one arm and lays it on the desk. He opens the computer's lid. A bright light fills the room.

Finder: Whoa! Where's that network drive? Waah! Ughh. Bleep boop. Fghzgh! Grrr! Zap Pow! Ahhhhhhhh!

Tyler: Calm down, Finder. It'll be ok. You're just on a different network.

Finder: But the network drive is goooooonnnnne!!!

Tyler: Your point? Simmer down and just pretend it never existed. I thought you were the world's most advanced operating system? Start acting like it.

Finder: But . . . but . . . what are you doing?! No! Don't press that!

The screen goes black as Tyler removes his finger from the power button.

And . . . Scene.

Ok, so maybe I'm being a little too dramatic, but this happens to me at least once a week. Luckily, there's a way to fix it.

Bernhard Baehr makes a wonderful utility called SleepWatcher which lets you assign scripts to run right before you machine goes to sleep or after it wakes up. Download and install.

Next, create a file in your home directory called ".sleep". SleepWatcher will run the commands in it as soon as it detects your system about to sleep. Add the following awk script to .sleep.

#!/bin/sh
mount | awk '/^afp_/ { system("umount -f " $3) }'

That command pipes a list of all mounted drives into awk and forcibly disconnects any AFP shares it finds.

Voila! No more Finder crashes.

posted by /
Tyler Hall

posted on /
05/11/2007

comments /
2


Tyler, I've got a solution to this problem that is entirely in a single shell script. What I do is run the script from a launchd process every 60 seconds. The script stores the MAC address of the current router and if this changes then the rest of the script runs. You'll also find that the awk script doesn't work if there is whitespace in the volume's name like "Macintosh HD". The awk script also will only unmount a single volume. I think we've overcome most of these limitations in my version. You could continue to use SleepWatcher and portions of this script but using launchd is just as easy. Andy

Andy Fragen
05/12/07
12:01 pm


I'm a recent convert to the Mac. One thing I've never figured out how to do is how to get a drive to remount after I've ejected it using only the keyboard. If I unplug the FireWire cable and plug it back in, that does it, but I've got to crawl under my desk to do that. Is there any way to do this without resorting to an esoteric Unix command-line mount command? Rob:-]

Rob
05/12/07
01:33 pm


comments


is your robot hungry? Subscribe to the feed

Raven SEO Tools

Snipplr Code Repository

Categories

Archives