If I have to commit one more time, I will have no choice but to sully my good logs...
authorTim Pope <code@tpope.net>
Wed, 1 Jun 2005 05:14:59 +0000 (05:14 +0000)
committerTim Pope <code@tpope.net>
Wed, 1 Jun 2005 05:14:59 +0000 (05:14 +0000)
perl/mobile-phone-monitor

index dbc549f08d54b6a06f8823e070ea76f9ea4c1811..5a46f1e2a954b2cad27540933daae393da8c9011 100755 (executable)
@@ -123,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";