summaryrefslogtreecommitdiffstats
path: root/regress/sys/kern/sosplice/tcp/args-unsplice-forked.pl
blob: 9b8ae668353fcfa542b2d19853da3d712449db9b (plain) (blame)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# test delay before server read, unsplice during client write

use strict;
use warnings;
use POSIX;

our %args = (
    client => {
	len => 2**17,
	func => sub { errignore(@_); write_stream(@_); },
    },
    relay => {
	func => sub {
	    my $self = shift;
	    defined(my $pid = fork())
		or die "relay func: fork failed: $!";
	    if ($pid == 0) {
		sleep 2;
		setsplice(\*STDIN)
		    or die ref($self), " unsplice stdin failed: $!";
		POSIX::_exit(0);
	    }
	    sleep 1;
	    eval { relay($self, @_) };
	    if ($self->{forward} =~ /splice/) {
		$@ =~ /^Relay sysread stdin has data:/
		    or die ref($self), " no data after unsplice: $@";
	    }
	    sleep 2;
	    kill 9, $pid;
	    (my $kid = waitpid($pid, 0)) > 0
		or die ref($self), " wait unsplice child failed: $!";
	    my $status = $?;
	    my $code;
	    $code = "exit: ".   WEXITSTATUS($?) if WIFEXITED($?);
	    $code = "signal: ". WTERMSIG($?)    if WIFSIGNALED($?);
	    $code = "stop: ".   WSTOPSIG($?)    if WIFSTOPPED($?);
	    $status == 0
		or die ref($self), " unsplice child status: $status $code";
	},
	rcvbuf => 2**10,
	sndbuf => 2**10,
    },
    server => {
	func => sub { sleep 3; read_stream(@_); },
    },
    noecho => 1,
    nocheck => 1,
    len => 131072,
    md5 => "31e5ad3d0d2aeb1ad8aaa847dfa665c2",
);