# Closing file descriptors

**URL:** <https://www.ruby-forum.com/t/closing-file-descriptors/92848>\
**Category:** Ruby\
**Created:** [April 24, 2007, 11:46pm UTC](https://www.ruby-forum.com/t/closing-file-descriptors/92848 "2007-04-24T23:46:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MenTaLguY](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@MenTaLguY](https://www.ruby-forum.com/u/MenTaLguY)\
**Post date:** [April 24, 2007, 11:46pm UTC](https://www.ruby-forum.com/t/closing-file-descriptors/92848/1 "2007-04-24T23:46:08Z")

</div>

Here’s a question I never thought I’d have to ask – how do I close a  
file descriptor opened via IO.sysopen ?

-mental

---

<div class="post-metadata">

**Author:** ![MenTaLguY](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@MenTaLguY](https://www.ruby-forum.com/u/MenTaLguY)\
**Post date:** [April 25, 2007, 12:29am UTC](https://www.ruby-forum.com/t/closing-file-descriptors/92848/2 "2007-04-25T00:29:13Z")

</div>

On Apr 24, 2007, at 5:45 PM, MenTaLguY wrote:

> Here’s a question I never thought I’d have to ask – how do I close  
> a file descriptor opened via IO.sysopen ?

IO.new(IO.sysopen(path)).close

Seems a bit round-about though.

Gary W.
