Author: sparky
Date: Mon Nov  2 23:45:01 2009
New Revision: 10930

Modified:
   toys/rsget.pl/RSGet/Line.pm
   toys/rsget.pl/RSGet/Main.pm
Log:
- added daemon option, not done correctly, but should work


Modified: toys/rsget.pl/RSGet/Line.pm
==============================================================================
--- toys/rsget.pl/RSGet/Line.pm (original)
+++ toys/rsget.pl/RSGet/Line.pm Mon Nov  2 23:45:01 2009
@@ -27,6 +27,7 @@
        return $term_size_columns;
 }
 
+my $nooutput = 0;
 our %active;
 my %dead;
 our @dead;
@@ -135,6 +136,7 @@
 
 sub update
 {
+       return if $nooutput;
        my $added = print_all_lines();
        print "\033[J\033[" . $added . "A\r" if $added;
 }
@@ -195,8 +197,16 @@
 
 sub init
 {
+       $nooutput = shift;
        $| = 1;
 
+       $SIG{__WARN__} = sub {
+               new RSGet::Line( "WARNING: ", shift );
+               update();
+       };
+
+       return if $nooutput;
+
        $SIG{INT} = sub {
                print_all_lines();
                print "\nTERMINATED\n";
@@ -212,11 +222,6 @@
                update();
        };
 
-       $SIG{__WARN__} = sub {
-               new RSGet::Line( "WARNING: ", shift );
-               update();
-       };
-
        $SIG{__DIE__} = sub {
                print_all_lines();
                print "\n";

Modified: toys/rsget.pl/RSGet/Main.pm
==============================================================================
--- toys/rsget.pl/RSGet/Main.pm (original)
+++ toys/rsget.pl/RSGet/Main.pm Mon Nov  2 23:45:01 2009
@@ -43,6 +43,11 @@
                desc => "User configuration file.",
                allowed => qr/.+/,
        },
+       daemon => {
+               desc => "Enter daemon mode. 1 - disable console output, 2 - 
also fork",
+               default => 0,
+               allowed => qr/[012]/,
+       },
 );
 
 our %usettings;
@@ -63,7 +68,8 @@
 
        check_settings( \%main::settings );
        read_userconfig();
-       RSGet::Line::init();
+       my $daemon = setting( "daemon" );
+       RSGet::Line::init( $daemon );
        print_settings() if verbose( 1 );
        RSGet::FileList::set_file();
        maybe_start_http();
@@ -78,6 +84,17 @@
        new RSGet::Line();
        RSGet::Line::update();
 
+       if ( $daemon == 2 ) {
+               my $pid = fork();
+               die "Cannot fork" unless defined $pid;
+               if ( $pid ) {
+                       print "rsget.pl daemon started on pid: $pid\n";
+                       exit 0;
+               }
+       } elsif ( $daemon ) {
+               print "rsget.pl daemon started successfully\n";
+       }
+
        loop();
 }
 
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to