- (__WARN__ => sub { err($self, @_) },
- PIPE => sub {
- $self->x_it(13); # SIGPIPE = 13
- # we need to close explicitly to avoid Perl warning on SIGPIPE
- for my $i (1, 2) {
- next unless $self->{$i} && (-p $self->{$i} || -S _);
- close(delete $self->{$i});
- }
- # trigger the LeiXSearch $done OpPipe:
- syswrite($self->{0}, '!') if $self->{0} && -p $self->{0};
- $SIG{PIPE} = 'DEFAULT';
- die bless(\"$_[0]", 'PublicInbox::SIGPIPE'),
- });
+ $current_lei = $self; # for SIG{__WARN__}
+}
+
+sub io_extract ($;@) {
+ my ($obj, @fields) = @_;
+ my @io;
+ for my $f (@fields) {
+ my $io = delete $obj->{$f} or next;
+ my @st = stat($io) or die "W: stat $obj.$f ($io): $!";
+ $obj->{"dev=$st[0],ino=$st[1]"} = $f;
+ push @io, $io;
+ }
+ @io