Perl / Perl/perl5

[feature] Provide a way to tell Perl not to close() a handle’s file descriptor

Open
#17,533 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature Request Needs Triage
Dominant language
Perl
Stars
2.3k
Forks
646
Avg merge
2d 22h
Merged PRs (30d)
49

Description

Per discussion just now with @Perl/perl-contributor

It’s a frustration point that, if you do:

open my $fh, '>>&=', $fd;

… Perl will close() the file descriptor once $fh is garbage-collected. While that’s useful behavior when $fd comes from, e.g., an exec() or file-descriptor pass via UNIX socket, if the $fd comes from an XSUB it’s often counterproductive since the XSUB may well want to use the file descriptor itself.

Currently this can be worked around by retaining a hash of ( $fd => $fh ), but “dangling filehandles” are rather ugly.

REQUEST: Provide a way to tell Perl that a given filehandle’s underlying file descriptor should not be close()d when the filehandle is garbage-collected.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the issue discussion and the shown open() form to understand the requested file-descriptor lifetime behavior and the intended API. Define what should happen when the handle is garbage-collected, then add coverage demonstrating both preserved and normally closed descriptors; the issue is done when the behavior is documented and tested.

Written by the indexing model from the issue text.

Assessment

Tech stack
perl
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.