Why am I getting a segmentation fault when I use binmode with threads in Perl?

Posted by jAndy on Stack Overflow See other posts from Stack Overflow or by jAndy
Published on 2010-04-15T09:50:11Z Indexed on 2010/04/16 4:03 UTC
Read the original article Hit count: 326

Filed under:
|

Hi Folks,

this call

my $th = threads->create(\&print, "Hello thread World!\n");
$th->join();

works fine. But as soon as I add

binmode(STDOUT, ":encoding(ISO-8859-1)");

to my script file, I get an error like "segmentation fault", "access denied".

What is wrong to define an encoding type when trying to call a perl thread?

Example:

use strict; use warnings;
use threads;

binmode(STDOUT, ":encoding(ISO-8859-1)");

my $th = threads->create(\&print, "Hello thread World!\n");
$th->join();

sub print {
    print @_;
}

This code does not work for me.

Kind Regards

--Andy

© Stack Overflow or respective owner

Related posts about perl

Related posts about threads