[plug] init.d script environments and perl and dd

Ryan ryan at is.as.geeky.as
Fri Aug 13 15:44:48 WST 2004


Howdy,

The topic is possibly misleading, but it's the most irrelevant search
friendly one I could come up with :)

I've written a Perl wrapper [1] around dd to do pretty bar graphs and
such by forking off a dd process, constantly USR1 signalling it and
processing the results.

On the command line it works 100% every time.

I have a machine that needs to take an image of one of its partitions to
a file and then at other times restore that file - these are not linux
partitions, so mounted/unmounted etc is not an issue.  To achieve this
I've put relevant LILO menu items which append a unique word to the
kernel

I then have an init script that is called on entering runlevel 2 which
reads /proc/cmdline to determine what action to perform from the
appended words and do an image/restore/nothing - that part is fine - it
always does the right thing.

When this script is called on entering runlevel 2, the Perl script runs,
but the dd process it forks returns with no errors and does nothing - it
does fork though, I can prove that much.  I've debugged the script to
the roof and dd simply returns a prompt without saying a word.  It does
this exactly 50% of the time.  Alternating between working and not
working in turn.  The only pattern is if I boot the machine first up it
will fail and return me a login prompt (when it works the script forces
a reboot).  If I login and 'reboot' then then next one will work, then
fail, then work ..... you get the picture :)

Could there me anything different about the environment the script is
running in that causes it to fail?  I've checked via the script that it
is running as root, everything is mounted, all the disks are synced,
that i can write/read the involved locations, i've put a 1 minute pause
in the script incase something was still loading and i've made the
script the last possible thing before rmnologin to load.

Anyone got any ideas?

[1] very dodgy code available on request - but it works 100% from the
command line - trust me :P

Thanks for reading all that,

Ryan




More information about the plug mailing list