[BusyBox] Race condition with tar zxf

Robert Kaiser rob at sysgo.de
Tue Mar 27 13:06:56 UTC 2001


Hi,

I just experienced an interesting problem with BusyBox tar
(current CVS version):

when extracting a compressed tar file onto a JFFS file system
with "tar zxvf", the last extracted file is always too short
by -in my case- ~3KB. This does not happen when the same tar
file is being extracted onto -for example- a RAMFS filesystem.
It also does not happen if I do a

 zcat <tarfile.tgz> | tar xvf -

rather than a

 tar zxvf <tarfile.tgz>

though both should really do the same thing.

The JFFS filesystem is relatively slow on writes, so, apparently
what happens is that the unzip process that busybox tar forks off
terminates before the tar process has begun processing the last
chunk of data. The termination of unzip triggers the signal handler
("child_died()") which in turn causes tar to exit prematurely
(i.e. before it has completely written the last file).

The attached "patch-sighand" fixes this problem by explicitly
retrieving the child's exit status and continuing if the child
exited normally.

However, I'm still wondering why we need this signal fuss at all.
I would expect that read() returns zero (indicating EOF) when the
gzip process at the other end of the pipe terminates and the pipe
is empty, so, not setting up a signal handler at all should work
fine. I have tried this (see the second attached "patch-no-sighand")
and it solved my problem just as well. Question is: have I broken
anything ?

What do you all think ?

Rob


----------------------------------------------------------------
Robert Kaiser                         email: rkaiser at sysgo.de
SYSGO RTS GmbH
Am Pfaffenstein 14                    phone: (49) 6136 9948-762
D-55270 Klein-Winternheim / Germany   fax:   (49) 6136 9948-10
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch-sighand
Type: text/x-c
Size: 575 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20010327/e8e719d2/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch-no-sighand
Type: text/x-c
Size: 538 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20010327/e8e719d2/attachment-0001.bin 


More information about the busybox mailing list