File: fork.pl

package info (click to toggle)
libscriptalicious-perl 1.15-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 180 kB
  • ctags: 70
  • sloc: perl: 1,150; makefile: 16
file content (23 lines) | stat: -rw-r--r-- 323 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

use strict;
use warnings;

use Scriptalicious;

sub schleep { select(undef,undef,undef,shift); }

defined(my $pid = fork()) or barf "fork failed; $!";

$pid or schleep(0.5);

start_timer();

schleep(0.5);

say "elapsed (".($pid?"parent":"child").") = ".show_delta();

wait() if $pid;

exit( ($? & 255) || ($?>>8) || 0);