[ACCEPTED]-Error code 141 with tar-error-code

Accepted answer
Score: 27

I realize this thread is more than a few 48 years old, but I'm commenting for those 47 people who stumble upon this thread with 46 the error.

Whenever you use a compression 45 option, tar implicitly opens a connection 44 to the underlying program using a pipe. So, in 43 the OP's example: tar -xvzf $filename.tar.gz, what tar will actually 42 do is run something similar to this: gunzip $filename.tar.gz | tar -xv -. You 41 can verify this by running a top, where you 40 will see two processes (one for tar and 39 one for gzip).

Sometimes though, the pipeline 38 itself breaks. For instance, if the file 37 is not a gzip file. Take this for example: tar -xvzf somefile.iso, which 36 would be equivalent to gunzip somefile.iso | tar -xv -. In such a situation, gzip 35 will error out. When gzip errors out, the 34 pipeline will break. Another possibility 33 would be if the gzip file was correct, but 32 the tar file inside of it was corrupt. In 31 this case, gzip starts sending the uncompressed 30 stream to tar, but then tar realizes something 29 is wrong and closes the stream. gzip here 28 would then error out, because it's output 27 is closed.

In exit values, a value above 26 128 indicates termination due to a signal, and 25 the amount above 128 signifies which signal 24 caused the termination. So, if we subtract 23 128 from the OP's exit code of 141, we get 22 13, which corresponds to SIGPIPE (man 7 signal for a 21 list of standard signals and their corresponding 20 integer values).

The man page lists SIGPIPE's 19 comment as "Broken pipe: write to pipe with 18 no readers". So then, it would appear that 17 gzip is trying to write to the pipe, but 16 tar has stopped listening. My guess here 15 is that gzip is uncompressing the file successfully, but 14 the uncompressed stream is not a valid tar 13 archive. My advice here would be to run 12 gunzip on the file, then run tar on the 11 result file and see which one fails (based 10 on the SIGPIPE, my guess here is that the 9 tar will fail). In either case, it looks 8 like the file isn't readable by these versions 7 of the tools (either corruption or a version 6 conflict of some kind).

How were these files 5 made (what options to tar, etc)? Are they 4 created on this machine or another machine? If 3 you create a .tar.gz file on this machine, can 2 this same machine extract those files without 1 the error?

Score: 1

GNU tar only returns a few things, none 6 of them being -141. however, if it's running 5 a subprocess, like gzip, and that process 4 terminates abnormally, it returns that return 3 code.

I'm not sure what the subprocess might 2 have been though. try it with --verbose and see 1 if you get any clues.

Score: 0

As a workaround we are now using cpio for 4 archiving, that works fine for us now, although 3 I would want to know why tar is causing 2 this issue, its around for long time, and 1 being used as standard tool for years.

More Related questions