|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57615 extract leaves a file descriptor
Submitted: 2007-04-08 09:19 UTC Modified: 2007-04-08 09:37 UTC
From: YLQUFHWNNUYL at spammotel dot com Assigned:
Status: Not a bug Package: rar (PECL)
PHP Version: 5.2.1 OS: win32
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: YLQUFHWNNUYL at spammotel dot com
New email:
PHP Version: OS:


 [2007-04-08 09:19 UTC] YLQUFHWNNUYL at spammotel dot com
i'm using the newest win32 binaries from the PECL package.
whenever i use extract, two file descriptors are opened, but only one gets closed by rar_close(), so it keeps one open for the archive for each time extract was called i believe...

this maybe just a problem with the compile for win32, or rar_close missing something...

--tacking on a feature request:
i believe this extension really needs the ability to get the file with some other way than extract... such as some way to be able to directly stream the file to something else
I'm using your extension to be able to download single files out of rar files i have stored, but the best way i've found to do it is extract to $tmpfile, then
$tosend = file_get_contents($tmpfile);
//start sending file

So it would be really nice to be able to load the extracted file into a string or something...

--side note
i'll probably post my script to the page about your extension, to help anyone at all interested in this extension with their code

Reproduce code:
$rar_file = rar_open($path.'/'.$file) or die("Can't open Rar archive");

$entry = rar_entry_get($rar_file, $fname) or die("Failed to find such entry");
if ($entry->extract(false, $tmpfile)) {

//or examples on the extract page (which one is missing even rar_close)

Expected result:
for it to open the rar file, then close all references to it, but it seems extract opens another reference which does not get closed... no matter what i do.

i'm seeing the open file list with a program called TaskInfo, but any advanced task manager probably could list them for someone

I don't know if there is any way to close the files by force in php because i'm fairly new to it... and don't know a way to reference that file anyways.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-08 09:37 UTC] tony2001 at phpclub dot net
>two file descriptors are opened, but only one gets closed by rar_close()
PECL/rar just uses unrar API, it doesn't open/close any files directly.
So if something goes wrong on a low level, this most likely means a problem in unrar.

>i believe this extension really needs the ability to get
>the file with some other way than extract..
Same here.
We're limited to the existing API of unrar.
It doesn't provide any way to get a stream, so we don't have much choice.

>i'll probably post my script to the page about your extension
If the script is really helpful, I may consider adding it to the documentation, so feel free to send the script to me.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Jan 21 04:01:23 2021 UTC