ManUtils: Fix possible deadlock on groff I/O
This commit is contained in:
parent
026a9bf2ad
commit
e33faef861
1 changed files with 5 additions and 0 deletions
|
|
@ -5,6 +5,7 @@ use IPC::Open3;
|
|||
use IO::Poll qw/POLLOUT POLLIN/;
|
||||
use Symbol 'gensym';
|
||||
use XSLoader;
|
||||
use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK);
|
||||
XSLoader::load('ManUtils');
|
||||
|
||||
sub fmt($input) {
|
||||
|
|
@ -27,6 +28,10 @@ sub fmt($input) {
|
|||
|
||||
my $pid = open3(my $in, my $out, my $err = gensym, @cmd);
|
||||
|
||||
# "POLLOUT" does NOT guarantee that a write will not block, we must set
|
||||
# O_NONBLOCK to tell the kernel that we can handle short writes.
|
||||
fcntl($in, F_SETFL, fcntl($in, F_GETFL, 0) | O_NONBLOCK);
|
||||
|
||||
my $inoff = 0;
|
||||
my $output = '';
|
||||
my $poll = IO::Poll->new;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue