September 2005


At work I have a collection of long-running Perl programs exec-ed by a rc script that have their noise redirected to a single intermingled log. The scripts themselves and the modules they use are littered with carps, warns and print STDERRs depending upon when and by whom they were written. I can differentiate their output (more or less) but I’d like it timestamped for forensic purposes.

My first thought, heaven help me, involving tying filehandles is exampled by this hack:

!/usr/local/bin/perl -w 

use Tie::Handle;
use Carp;
use strict; 

package TimeStamper; 
@ISA = qw(Tie::Handle); 

sub wrap { 
    my $fh = shift; 
    my $fh_name = $fh; 
    $fh_name =~ s/^\*//;
    local *MYFH; 
    open(MYFH, ">&$fh_name") or die("Failed to dupe [$fh_name]: $!"); 
    tie($fh,'TimeStamper',*MYFH); 
} 

sub TIEHANDLE { 
     my ($class,$fh) = @_; 
     my $obj = bless [$fh],$class; 
     return $obj; 
} 

sub PRINT { 
    my $self = shift; 
    my $fh   = $self->[0]; 
    my @t = localtime(); 
    print sprintf("[%4d/%02d/%02d %02d:%02d:%02d] ", 
                  $t[5]+1900,@t[4,3,2,1,0]),@_; 
} 

package main; 

TimeStamper::wrap(*STDERR);
print STDERR "This is timestamped.\n";
warn('This is timestamped.'); 
carp('This is timestamped.');
print "This is not timestamped.\n"; 

Neat. Even half clever. But I’m not sure it’s a good idea.

Today’s parenting realization: being an infant is like being a bad drunk- you wake up somewhere other than where you fell asleep, in a different set of clothes and with all these people you don’t know around you.

Today’s parenting realization: Even a simple task is a variation on the Tower of Hanoi puzzle when you have a baby in one arm.

I’ve decided to take a hiatus from Debian Linux on my primary desktop. This box is only the latest hardware permutation beneath what started long ago as a “Slink” install, but a recent 2.6 kernel reordered devices, including the root disk (whee!), and older kernels don’t support the Soyo KT600 motherboard very well. I was stuck either with partial support or an install. It didn’t help that I had done numerous in-place upgrades, chased the unstable branch, compiled or alien-ed my own packages and occasionally built custom kernels.

So I installed… FreeBSD 5.4. I prefer the BSDs and the desktop was the only box in the house running Linux. I chose to slice off another 18G chunk from the SATA drive and away I went.

Well, sort of. I spent an evening and late night (they’re all late nights when you have a three month old, but that’s another topic) fighting a kernel panic that occurred under heavy I/O load, the kind of load that, say, installing the distributions produces. If it visibly trapped I would get something similar to the below, cribbed onto the notepad I always keep nearby when I fiddle with systems, but often it would die more quietly and reboot:

Fatal Trap 12: page fault while in kernel mode
fault virtual address = 0xd8
fault code = supervisor read, page not present
instruction pointer = 0x8:0xc07550fc
stack pointer = 0x10:0xd95129f8
frame pointer = 0x10:0xd95120c28
code segment = base 0x0 limit 0xfffff type 0x15
DPL 0, pres 1, def 32 1, gran 1
processor eflags = interrupt enabled, resume, IPL
current process = 835 (bsdtar)

Turns out that a BIOS setting provokes it. I set the “System Performance” to ‘Normal’ and the kernel panic went away. I have no idea what that tweaks but I was quickly done with the base, a distribution set and off to the ports collection to build some of my preferred software- fluxbox, muttng, xemacs, firefox, irssi, crm114, cmucl, TeX, apache, etc. Copying over selected portions and configuration from the ext2fs partitions will take some time and I may have to fiddle with running a couple of things under Linux emulation but I’m pretty much all in order in an evening.

A previous owner of my motorcycle at some time had the fusebox work loose and touch the exhaust pipe behind the muffler. They concealed the mess of hardened plastic slag by wrapping the whole in electric tape and zip tying it in place. I found this when I popped a fuse while replacing the rear tail light with an LED unit. Not good. Fortunately, BMW keeps an amazing parts inventory and Max’s BMW was able to get me the parts in a week.

Nathan slept, Maria read and I wrenched for an hour. Almost as good as new. I had to reuse the damaged rubber weather boot- the part number had melted away and I couldn’t find it in the parts fiche- but I wrapped the burned spot in good electrical tape. Not the greatest solution but at least the fusebox itself is sealed and mounted instead of rattling around in pieces.

Next Page »