summaryrefslogtreecommitdiffstats
path: root/examples/root/bin/sleeper
blob: 6c14959280eb77465236728640e0c4fd906df312 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/perl -w

###
# sleep indefinitely as a debug

use strict;
use Getopt::Long;
use Pod::Usage;

#-----------------------------------------------------------------
sub daemonize
{
	 use POSIX 'setsid';
	 $| = 1;
	 chdir '/'					  or die "Can't chdir to /: $!\n";
	 open STDIN, "/dev/null"		or die "Can't read /dev/null: $!\n";
	 open STDOUT, "> /dev/null"	 or die "Can't write to /dev/null: $!\n";
	 defined(my $pid = fork())	  or die "Can't fork: $!\n";
	 #print STDERR $pid, "\n";
	 exit if $pid;
	 setsid						 or die "Can't start a new session: $!\n";
	 open STDERR, ">&STDOUT"		or die "Can't dup stdout: $!\n";
}
#-----------------------------------------------------------------

my ($help,$opt_result,$debug,$fun);

$opt_result = GetOptions
(
	"help" => \$help,
	"debug" => \$debug,
	"fun" => \$fun,
);

if (! $opt_result)
{
	pod2usage('-exitval' => 1, '-verbose' => 0);
	exit(1);
}

if ($help)
{
	pod2usage('-exitval' => 1, '-verbose' => 2);
	exit;
}

unless ($debug) {
	daemonize();
}

while(1){
	sleep 600;
}

=head1 NAME

template - this is a template script and should be copied and modded

=head1 SYNOPSIS

template [-help]

=head1 DESCRIPTION

B<template> is a stub script.

=head1 OPTIONS

=over 4

=item help

Prints out help page.

=back

B<Example>

template

=head1 BUGS

This script shouldn't be modified, or has apparently not been documented.

=head1 SEE ALSO

L<Cat>

=head1 AUTHOR

Luke A. Kanies, luke.kanies@cat.com

=for html <hr>

I<$Id$>

=cut