File: prefork-interp-test

package info (click to toggle)
chiark-utils 8.0.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,084 kB
  • sloc: ansic: 4,640; perl: 4,281; sh: 671; python: 465; makefile: 286; tcl: 228
file content (32 lines) | stat: -rwxr-xr-x 662 bytes parent folder | download | duplicates (2)
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
31
32
#!/usr/bin/prefork-interp -U,perl,-w
# -*- perl -*-

# Copyright 2022 Ian Jackson and contributors to chiark-utils
# SPDX-License-Identifier: GPL-3.0-or-later
# There is NO WARRANTY.

use strict;
use Proc::Prefork::Interp;

sub prwhen ($) {
  my ($when) = @_;
  my @env = sort keys %ENV;
  print STDERR "$when - STDERR - @ARGV - $ENV{PREFORK_INTERP} - @env\n"
    and flush STDERR or die $!;
  print STDOUT "$when - STDOUT\n"
    and flush STDOUT or die $!;
}

prwhen('BEGIN');

prefork_initialisation_complete();

prwhen('AFTER');

while (<STDIN>) {
  last unless m{\S};
  $_ = uc $_;
  print or die $!;
  flush STDOUT or die $!;
  print STDERR length, "\n";
}