Skip to content

Leaves STDERR in line buffered mode #63

@grr

Description

@grr

After using capture(), STDERR is left in line buffered mode, i.e. it is no longer "hot". You have to manually set $| to restore unbuffered mode.

Example program demonstrating the issue:

#!/usr/bin/env perl
use v5.10;
use strict;
use warnings;
use Capture::Tiny qw(capture);

print STDERR __LINE__;  # prints immediately as expected

# my $out = `date`;  # stderr is fine if using this line instead of the next
my ($out, $err) = capture { system 'date' };  # leaves stderr in buffered mode
say $out;

# $| = 1, select $_ for select STDERR;
# won't print unless prev line is uncommented or script exits normally.
print STDERR __LINE__;
sleep 10;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions