#!/usr/bin/perl -- use strict; use warnings; use autodie qw/ open close /; use threads stack_size => 4096; package test; sub doit { my $self = {}; my $FOO; open $FOO, '<', 'WISDOM.ico' or die $!; my $threadcode = sub { close $FOO; eval { close $FOO; 1 } or warn $@; sleep 60; return; }; $self->{'th'} = threads->create($threadcode); close $FOO; eval { close $FOO; 1 } or warn $@; bless $self; } sub joinit { my ($self) = @_; my $th = $self->{'th'}; $th->join(); } my $t = test::doit(); print "thread created\n"; # OS Tests here indicate the file descriptor is closed $t->joinit(); print "thread ended\n"; sleep 100;