From ed1ad9b3b6ea3e6e22deaaf54fdc8230a3b09b8c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 7 Oct 2023 21:24:09 +0000 Subject: process_io: pass args to awaitpid as list Specifying {cb_args} in the options hash felt awkward to me. Instead, just use the Perl stack like we do with awaitpid() and pass the list down directly. --- t/spawn.t | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 't') diff --git a/t/spawn.t b/t/spawn.t index be5aaf9f..1af66bda 100644 --- a/t/spawn.t +++ b/t/spawn.t @@ -140,13 +140,13 @@ EOF { # ->CLOSE vs ->DESTROY waitpid caller distinction my @c; - my $fh = popen_rd(['true'], undef, { cb_arg => [sub { @c = caller }] }); + my $fh = popen_rd(['true'], undef, undef, sub { @c = caller }); ok(close($fh), '->CLOSE fired and successful'); ok(scalar(@c), 'callback fired by ->CLOSE'); ok(grep(!m[/PublicInbox/DS\.pm\z], @c), 'callback not invoked by DS'); @c = (); - $fh = popen_rd(['true'], undef, { cb_arg => [sub { @c = caller }] }); + $fh = popen_rd(['true'], undef, undef, sub { @c = caller }); undef $fh; # ->DESTROY ok(scalar(@c), 'callback fired by ->DESTROY'); ok(grep(!m[/PublicInbox/ProcessIO\.pm\z], @c), @@ -157,8 +157,8 @@ EOF use POSIX qw(_exit); pipe(my ($r, $w)) or BAIL_OUT $!; my @arg; - my $cb = [ sub { @arg = @_; warn "x=$$\n" }, 'hi' ]; - my $fh = popen_rd(['cat'], undef, { 0 => $r, cb_arg => $cb }); + my $fh = popen_rd(['cat'], undef, { 0 => $r }, + sub { @arg = @_; warn "x=$$\n" }, 'hi'); my $pp = tied *$fh; my $pid = fork // BAIL_OUT $!; local $SIG{__WARN__} = sub { _exit(1) }; -- cgit v1.2.3-24-ge0c7