File: run_daemon

package info (click to toggle)
libipc-run-perl 0.94-1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 748 kB
  • sloc: perl: 5,750; makefile: 5
file content (19 lines) | stat: -rw-r--r-- 340 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/perl -w

## An example of how to daemonize.  See the IPC::Run LIMITATIONS section for
## some reasons why this can be a bit dangerous.

use strict ;

use IPC::Run qw( run close_terminal ) ;

run(
   sub {
      # ... your code here ...
      sleep 15 ;
   },
   init => sub {
      close_terminal ;
      exit if fork ;
   }
) ;