=================================================================== RCS file: /cvs/openbsd/OpenBSDTorrents/NewTorrents.pl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- openbsd/OpenBSDTorrents/NewTorrents.pl 2005/03/24 05:32:49 1.2 +++ openbsd/OpenBSDTorrents/NewTorrents.pl 2005/03/25 03:13:45 1.3 @@ -1,5 +1,5 @@ #!/usr/bin/perl -T -#$Id: NewTorrents.pl,v 1.2 2005/03/24 05:32:49 andrew Exp $ +#$Id: NewTorrents.pl,v 1.3 2005/03/25 03:13:45 andrew Exp $ use strict; use warnings; use diagnostics; @@ -7,10 +7,14 @@ use lib 'lib'; use OpenBSDTorrents; +use POSIX 'setsid'; + %ENV = (); use YAML; +# *** This requires --log-format="%t [%p] %o %f %l" on the rsync command + my $last_dir = ''; while (<>) { chomp; @@ -29,11 +33,35 @@ } StartTorrent($last_dir); +sleep(90); + +StartTorrent('skip'); + + sub StartTorrent { my $dir = shift; + return undef unless $dir; + if ($dir ne 'skip') { + $dir = "$BaseName/$dir"; + } + # This actually needs to be a sub that forks off # the generation of this, and the running of the update script. print "MakeTorrents.pl $BaseName/$dir\n"; + + defined(my $pid = fork) or die "Can't fork: $!"; + + return if $pid; + + chdir $HomeDir or die "Can't chdir to $HomeDir: $!"; + + setsid or die "Can't start a new session: $!"; + #open STDIN, '/dev/null' or die "Can't read /dev/null: $!"; + #open STDOUT, '>/dev/null' + # or die "Can't write /dev/null: $!"; + #open STDERR, '>&STDOUT' or die "Can't dup stdout: $!"; + + exec('/home/andrew/OpenBSDTorrents/regen.sh', "$dir"); }