Assorted away-tpope updates
[tpope-extra.git] / perl / mobile-phone-monitor
index 5c7065f5c0f36ea8752cc0ba3490eb92a022c787..5a46f1e2a954b2cad27540933daae393da8c9011 100755 (executable)
@@ -51,7 +51,6 @@ while($status{"is_active"} ne 0) {
        } elsif(!defined($number)) { $status{"is_active"}=0; last; };
     }
     my %newstatus=gather_data($gsm);
-    print $newstatus{'call'}." ".$status{'call'}."\n";
     ring() if($newstatus{"call"}!=0 && $status{"call"}==0 && !$status{"number"});
     foreach (keys %newstatus) {
        $status{$_} = $newstatus{$_} if(defined ($newstatus{$_}));
@@ -124,6 +123,21 @@ sub output_status {
     rename "/tmp/.phone-status.new", "/tmp/.phone-status" || die $!;
 }
 
+sub daemonize {
+    chdir "/";
+    my $pid=fork();
+    if($pid) {
+       exit(0)
+    }
+    elsif(defined($pid))
+    {
+       close STDIN;
+       close STDOUT;
+       close STDERR;
+    }
+    else { exit(1); }
+}
+
 sub death {
     $gsm->disconnect() if($gsm);
     unlink "/tmp/.phone-status.new", "/tmp/.phone-status";