]> Sergey Matveev's repositories - public-inbox.git/blobdiff - script/lei
syscall: implement sendmsg+recvmsg in pure Perl
[public-inbox.git] / script / lei
index 8f6e8aacb86b67470d2dade0fdd7225cc6e7df0a..adef9944288d91f396a0be0be50f6412d4779de2 100755 (executable)
@@ -1,5 +1,5 @@
 #!perl -w
-# Copyright (C) 2020-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
 use v5.10.1;
@@ -9,6 +9,10 @@ my $narg = 5;
 my $sock;
 my $recv_cmd = PublicInbox::CmdIPC4->can('recv_cmd4');
 my $send_cmd = PublicInbox::CmdIPC4->can('send_cmd4') // do {
+       require PublicInbox::Syscall;
+       $recv_cmd = PublicInbox::Syscall->can('recv_cmd4');
+       PublicInbox::Syscall->can('send_cmd4');
+} // do {
        my $inline_dir = $ENV{PERL_INLINE_DIRECTORY} //= (
                        $ENV{XDG_CACHE_HOME} //
                        ( ($ENV{HOME} // '/nonexistent').'/.cache' )
@@ -107,8 +111,8 @@ my $buf = join("\0", scalar(@ARGV), @ARGV);
 while (my ($k, $v) = each %ENV) { $buf .= "\0$k=$v" }
 $buf .= "\0\0";
 $send_cmd->($sock, [0, 1, 2, fileno($dh)], $buf, MSG_EOR) or die "sendmsg: $!";
-$SIG{TSTP} = sub { $send_cmd->($sock, [], 'STOP', MSG_EOR); kill 'STOP', $$ };
-$SIG{CONT} = sub { $send_cmd->($sock, [], 'CONT', MSG_EOR) };
+$SIG{TSTP} = sub { send($sock, 'STOP', MSG_EOR); kill 'STOP', $$ };
+$SIG{CONT} = sub { send($sock, 'CONT', MSG_EOR) };
 
 my $x_it_code = 0;
 while (1) {