Statistics
| Branch: | Tag: | Revision:

dvbd / utils / cgi / radio.cgi @ 723fa73a

History | View | Annotate | Download (689 Bytes)

1
#!/usr/bin/perl
2
use CGI;
3
use POSIX 'setsid';
4

    
5
$q = new CGI;
6
print $q->header;
7
print "<pre>";
8
$station = $q->param('station');
9
print "<pre>Play Radio $station...\n</pre>";
10
$SIG{'CHLD'}="IGNORE";
11
if (fork() == 0) {
12
    daemonize();
13
    exec("/home/jak/bin/radio", $station);
14
}
15

    
16
sub daemonize {
17
    chdir '/'               or die "Can't chdir to /: $!";
18
    open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
19
    open STDOUT, '>/dev/null'
20
		   or die "Can't write to /dev/null: $!";
21
    defined(my $pid = fork) or die "Can't fork: $!";
22
    exit if $pid;
23
    setsid                  or die "Can't start a new session: $!";
24
    open STDERR, '>&STDOUT' or die "Can't dup stdout: $!";
25
}
26