File: simple.pl

package info (click to toggle)
libproc-fork-perl 0.807-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 136 kB
  • sloc: perl: 165; makefile: 2
file content (30 lines) | stat: -rw-r--r-- 362 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
24
25
26
27
28
29
30
use strict;
use Proc::Fork;

use IO::Pipe;
my $p = IO::Pipe->new;

run_fork {
	parent {
		my $child = shift;
		$p->reader;
		print while <$p>;
		waitpid $child,0;
	}
	child {
		$p->writer;
		print $p "Line 1\n";
		print $p "Line 2\n";
		exit;
	}
	retry {
		if( $_[0] < 5 ) {
			sleep 1;
			return 1;
		}
		return 0;
	}
	error {
		die "That's all folks\n";
	}
};