Skip to content

Respect IO layers on the standard handles #8

@hakonhagland

Description

@hakonhagland

Maybe the module should respect (i.e. forward) that IO layers on the standard handles
when it reopens them?

Example:

use feature qw(say);
use strict;
use warnings;
use open qw/:std IN :encoding(utf-8) OUT :utf8/; 
use Cwd qw(getcwd);
use Proc::Daemon;

say  join ' ', (PerlIO::get_layers(\*STDOUT));
my $work_dir = getcwd;    
my $daemon = Proc::Daemon->new(
    work_dir     => $work_dir,
    child_STDOUT => 'stdout.txt',
    child_STDERR => 'stderr.txt',
    pid_file     => 'pid.txt',
);
my $pid = $daemon->Init();
if ( $pid == 0 ) {
    say  join ' ', (PerlIO::get_layers(\*STDOUT));
}

The output from the script is:

unix perlio utf8

but the output to file stdout.txt is missing the utf8 layer:

unix perlio

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions