diff options
author | Eric Wong <e@80x24.org> | 2023-11-02 09:35:33 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-11-03 06:39:30 +0000 |
commit | cfe25e6aa966144a9c96d1ba2c301fd5e1bad79b (patch) | |
tree | 4faa9092c422aafca9568e547634096da12667e9 /lib/PublicInbox/Spawn.pm | |
parent | 16957ad7c4edcbf43294e67c8db06167594f0660 (diff) | |
download | public-inbox-cfe25e6aa966144a9c96d1ba2c301fd5e1bad79b.tar.gz |
This fixes two major problems with the use of tie for filehandles: * no way to do fcntl, stat, etc. calls directly on the tied handle, forcing callers to use the `tied' perlop to access the underlying IO::Handle * needing separate classes to handle blocking and non-blocking I/O As a result, Git->cleanup_if_unlinked, InputPipe->consume, and Qspawn->_yield_start have fewer bizzare bits and we can call `$io->blocking(0)' directly instead of `(tied *$io)->{fh}->blocking(0)' Having a PublicInbox::IO class will also allow us to support custom read buffering which allows inspecting the current state.
Diffstat (limited to 'lib/PublicInbox/Spawn.pm')
-rw-r--r-- | lib/PublicInbox/Spawn.pm | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/PublicInbox/Spawn.pm b/lib/PublicInbox/Spawn.pm index b4f37bea..d3b7ef6f 100644 --- a/lib/PublicInbox/Spawn.pm +++ b/lib/PublicInbox/Spawn.pm @@ -19,7 +19,7 @@ use PublicInbox::Lock; use Fcntl qw(SEEK_SET); use IO::Handle (); use Carp qw(croak); -use PublicInbox::ProcessIO; +use PublicInbox::IO; our @EXPORT_OK = qw(which spawn popen_rd popen_wr run_die run_wait run_qx); our @RLIMITS = qw(RLIMIT_CPU RLIMIT_CORE RLIMIT_DATA); use autodie qw(open pipe seek sysseek truncate); @@ -377,7 +377,7 @@ sub popen_rd { my ($cmd, $env, $opt, @cb_arg) = @_; pipe(my $r, local $opt->{1}); my $pid = spawn($cmd, $env, $opt); - PublicInbox::ProcessIO->maybe_new($pid, $r, @cb_arg); + wantarray ? ($r, $pid) : PublicInbox::IO::attach_pid($r, $pid, @cb_arg) } sub popen_wr { @@ -385,7 +385,7 @@ sub popen_wr { pipe(local $opt->{0}, my $w); $w->autoflush(1); my $pid = spawn($cmd, $env, $opt); - PublicInbox::ProcessIO->maybe_new($pid, $w, @cb_arg) + wantarray ? ($w, $pid) : PublicInbox::IO::attach_pid($w, $pid, @cb_arg) } sub read_out_err ($) { |