6 my $body_filename = $ARGV[0];
7 my @command = @ARGV[1 .. $#ARGV];
10 my $body_size = -s
$body_filename;
11 $ENV{"CONTENT_LENGTH"} = $body_size;
12 open(my $body_fh, "<", $body_filename) or die "Cannot open $body_filename: $!";
14 defined read($body_fh, $body_data, $body_size) or die "Cannot read $body_filename: $!";
23 my $pid = open(my $out, "|-", @command);
25 # disable buffering at $out
26 my $old_selected = select;
31 print $out $body_data or die "Cannot write data: $!";
33 sleep 60; # is interrupted by SIGCHLD
36 die "Command did not exit after reading whole body";