[Gambas-user] Pipe EOF
Admin
admin at allunix.ru
Wed Dec 25 08:17:58 CET 2019
So, I have this piece of code:
---------------------------------
Dim PackSize As Integer
Dim packet As String
Dim archive As File
Dim outgoing As File
Dim NeededTransactions As Integer
Dim transaction As Integer
Dim OnePercent As Integer
archive = Pipe "~/base.tar.gz" For Read
outgoing = Pipe "/tmp/install" For Write
PackSize = Stat("~/base.tar.gz").Size
NeededTransactions = Int(Val(Label1.Text) / 8192)
OnePercent = Int(Val(Label1.Text) / 100)
Shell ("tar --same-owner -xzpf /tmp/install -C /")
For transaction = 0 To NeededTransactions
Read #archive, packet, -8192
Write #outgoing, packet
Label1.Text -= Len(packet)
ProgressBar1.Value = (PackSize - Val(Label1.Text)) / OnePercent / 100
Wait
Next
Wait 10
Close #archive
Close #outgoing
Wait 10
Shell "ps ax | grep tar"
----------------------------------------
base.tar.gz is basically a Linux installation in a tarball with a packed
path starting with /mnt, so when it is untared, it copies a full Linux
system to /mnt assuming there's a new drive mounted. I can untar it
manually in a terminal, then install Grub, and the system boots
successfully.
When this code is executed, my progress bar fills to 100%, my "bytes
left" Label1 eventually becomes zero, and #archive and #outgoing get
closed succesfully. All 123849 files appear in /mnt as intended.
But when that last ps ax is executed - tar is still there. And the
system boots to kernel panic stating that /sbin/init cant be ran because
of Permission Denied, which tells me that tar clearly didn't go well.
If, after I get to 100% and zero bytes left, I simply do this in terminal:
cat /dev/zero > /tmp/install
tar immidiately prints into gambas IDE's terminal that it has
successfully finished unpacking, the command (cat /dev/zero) terminates
almost immidiatly after start, and the system boots fine.
So, I wonder if closing a pipe does not actually send EOF to the pipe
despite stating this exact behaviour in documentation, or am I missing
somethig?
Best regards
Dmitry Bachilo.
More information about the User
mailing list