Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8153113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:54:43+00:00 2026-06-06T15:54:43+00:00

I am uncompressing a .gz-file and putting the output into tar with php. My

  • 0

I am uncompressing a .gz-file and putting the output into tar with php.
My code looks like

$tar = proc_open('tar -xvf -', array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'a')), &$pipes);
$datalen = filesize('archive.tar.gz');
$datapos = 0;
$data = gzopen('archive.tar.gz', 'rb');
while (!gzeof($data))
{
    $step = 512;
    fwrite($pipes[0], gzread($data, $step));
    $datapos += $step;
}
gzclose($data);
proc_close($tar);

It works great (tar extracts a couple directories and files) until a bit more than halfway in (according to my $datapos) the compressed file, then the script will get stuck at the fwrite($pipes...) line forever (i waited a few minutes for it to advance).

The compressed archive is 8425648 bytes (8.1M) large, the uncompressed archive is 36720640 bytes (36M) large.

What am I possibly doing wrong here, since I havn’t found any resources considering a similar issue?

I’m running php5-cli version 5.3.3-7+squeeze3 (with Suhosin 0.9.32.1) on a 2.6.32-5-amd64 linux machine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T15:54:44+00:00Added an answer on June 6, 2026 at 3:54 pm

    1 => array('pipe', 'w')

    You have tar giving you data (file names) on stdout. You should empty that buffer. (I normally just read it.)

    You can also send it to a file so you don’t have to deal with it.

    1 => array('file', '[file for filelist output]', 'a')

    if you’re on Linux, I like to do

    1 => array('file', '/dev/null', 'a')

    [Edit: Once it outputs enough, it’ll wait for you to read from standard out, which is where you are hanging.]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The thing is like this. I have a zip file with images that uncompressing
Is it possible to list the contents of a LZMA file (.7zip) without uncompressing
In a long run command line execution, like uncompressing a large .zip archive, how
we are deflating the php files for compression, performance, etc. the .htaccess file syntax
I have this following code for bringing page attachments to the user: private void
I am uncompressing some data from double words. unsigned char * current_word = [address
I have a text file that I want to compress after it gets an
I've been using (Ubuntu's) file-roller to compress a range of files, e.g. .gz, .zip,
Suppose I've got some Arch Linux installation which I'd like to distribute among students
I am sending large datasets in JSON format from my server (using PHP). I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.