#!/usr/bin/perl -w
#
# YoDaemon version 0
# Launches Yahoo Mail as a daemon
#
# Copyright Dirk Diggler & Som One 1981-2002. All rides reserved.
# Coded by Som One and Pierrot Lunaire (French version)
# Redistribution and use, with or without modification,
# is permitted in the sense of GDWYWL
# (GeneralDoWhateverYouWantLicense)
# -z3r0-

use strict;

chomp(my $am_i_ubermensch = `id -u 2>/dev/null`);
die "It ain\'t clever running YoDaemon as root! Exiting.\n"
        if $am_i_ubermensch eq '0';

if ((! defined $ARGV[0]) || (! defined $ARGV[1])) {
	print "YoDaemon: Missing argument(s)!\n\n".
	      "Usage: YoDaemon COMMAND PERIOD\n";
	die "Runs COMMAND every PERIOD minutes.\n";
	
}

die "YoDaemon: Second argument must be a number!\n" if ($ARGV[1] !~ /^[0-9]+$/);

# I don't like the zombie kids! :-)
$SIG{CHLD} = 'IGNORE';

my $pid = fork;
exit if $pid;
die "Couldn't fork: $!" unless defined ($pid);

do {
`$ARGV[0]` or die "\n";
sleep $ARGV[1]*60;
} until (my $heslo);
