tar bugfix patch n.347 (recoded, version 4)
Roberto A. Foglietta
me at roberto.foglietta.name
Thu Dec 22 15:47:07 UTC 2005
Vladimir N. Oleynik ha scritto:
> Roberto and Rob,
Sorry for the double post but I tried to made some tests to get a
glimpse light more on the issue fork/vfork and pipe/async child managment.
> My reall busybox router have script:
>
> $ tar cf - /etc /bin/ /usr /home | ( cd /mnt/copy_here; tar xf - )
>
> for save configuration.
>
> Its make
> - double shell to memory
> - double tar to memory
>
> We can`t change fork() to vfork() trivially, this applets use BSS
> variables (prezeroed) and for vfork() is not separetelly.
>
trivially it does not work, fail correctly but hangs in case of success
[roberto at wsraf busybox-1.01_raf]$ ./busybox tar tvzf /tmp/test.tar.gz0
tar: unexpected end of file
tar: null size tar archive
[roberto at wsraf busybox-1.01_raf]$ ./busybox tar tvzf /tmp/test.tar.gz
roberto 22515 0.0 0.0 1792 424 ? S Dec21 0:00
tar xvjf /tmp/test.tar.bz2 busybox
roberto 22516 0.0 0.2 5308 1428 ? S Dec21 0:00
\_ tar xvjf /tmp/test.tar.bz2 busybox
a vfork busybox tar is running on my workstation since yesterday...
...and it is growing!!!
;-)
>> http://www.erlenstar.demon.co.uk/unix/faq_2.html
>>
>> which document are talking about zombies too and how to preventing
>> they happen. Solaris docs was read just because I worked on solaris hw
>> but actually I do not have any such hw.
>
>
> This zombie have very small life. ;-)
> After parent readed last pipe buffer, parrent exited also.
> "Tar" is not a daemon server, using async sigchild handler is nonsense.
> You can found true Unix documentation with typically example with
> fork()+pipe().
>
I think you are right about zombie very small life.
Applaying patch n.4 and restoring original open_transform.c works too:
[roberto at wsraf busybox-1.01_raf]$ ./busybox tar tvzf /tmp/test.tar.gz
-rw-r--r-- 0/0 133490 2005-11-18 10:20:23 ../volantino_LD05.pdf
[roberto at wsraf busybox-1.01_raf]$ ./busybox tar tvzf /tmp/test.tar.gz0
tar: unexpected end of file
tar: null size tar archive
but with original open_transform.c every applets like rpm which call
open_transform has to be instructed to find zero lenght file/data and
exit with error in order to return a coherent exit status in case of
child failure.
Everyone whom (will) write an applet which use open_transform has to
be acknowledged of this. Async child managment resolve this issue
defintely. I did not manage to do the same with fork+pipe, not for all
failure conditions, perhaps. Please if you know where I am wrong let me
known.
I have done some tests to check how much n.4 patch sucks...
This is the file size of bb-1.01 original compiled with default config
[roberto at wsraf busybox-1.01]$ ls -al busybox
-rwxr-xr-x 1 roberto users 237032 dic 22 15:56 busybox*
[roberto at wsraf busybox-1.01]$ md5sum busybox
c47e7323c2a269856a6f5b46dbcf360f busybox
This is the file size of bb-1.01 patched compiled with default config
[roberto at wsraf busybox-1.01_raf]$ ls -al busybox
-rwxr-xr-x 1 roberto users 237032 dic 22 15:54 busybox*
[roberto at wsraf busybox-1.01_raf]$ md5sum busybox
7043c59660c1b9748278c57e27647137 busybox
So at least under the point of view of storage patch n.4 do not add
anything... Unbelivable... I do *NOTHING*
;-)
emh.. why a such thing could happen? Two different branch of the same
binary which has the *exactly* same file size and different behaviure?
From the point of view of memory usage original busybox and patched
one with n.4 appear the same, at least using this method:
./busybox tar xz - >/dev/null &
ps wl $!
or adding a system("ps wl"); in the parent proccess:
[roberto at wsraf busybox-1.01_raf]$ ./busybox tar tvzf /tmp/test.tar.gz
F UID PID PPID PRI NI VSZ RSS WCHAN STAT TTY TIME COMMAND
0 1309 7150 28474 17 0 1796 444 wait S+ pts/3 0:00 tar
tvzf /tmp/test.tar.gz
1 1309 7151 7150 17 0 1796 520 pipe_w S+ pts/3 0:00 tar
tvzf /tmp/test.tar.gz
[roberto at wsraf busybox-1.01]$ ./busybox tar tvzf /tmp/test.tar.gz
0 1309 7165 28474 16 0 1796 444 wait S+ pts/3 0:00 tar
tvzf /tmp/test.tar.gz
1 1309 7166 7165 16 0 1796 520 pipe_w S+ pts/3 0:00 tar
tvzf /tmp/test.tar.gz
may be better memory usage benchmark than ps could reveal differences.
Cheers,
--
Roberto A. Foglietta
http://www.roberto.foglietta.name
SkypeNick: robang74
ICQ#: 108718257
More information about the busybox
mailing list