bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

cpio terminates prematurely if its output is piped through head


From: Elmar Stellnberger
Subject: cpio terminates prematurely if its output is piped through head
Date: Sat, 09 May 2009 11:27:00 +0100
User-agent: Thunderbird 2.0.0.19 (X11/20081227)

cpio terminates prematurely if its output is piped through head:
using cpio-2.9-75.45

cpio -idv './usr/include/*' 'usr/include/*' <$a 2>&1
... fully unpacks the archive $a

cpio -idv './usr/include/*' 'usr/include/*' <$a 2>&1 | head
... unpacks apparently non-deterministically just some but not all files
of arcive $a

> find ./usr >files$i.lis
> ls -l files*.lis
-rw-r--r-- 1 elm users   884  9. Mai 10:54 files10.lis
-rw-r--r-- 1 elm users   884  9. Mai 10:54 files1.lis
-rw-r--r-- 1 elm users  3896  9. Mai 10:54 files2.lis
-rw-r--r-- 1 elm users  4933  9. Mai 10:54 files3.lis
-rw-r--r-- 1 elm users  5271  9. Mai 10:54 files4.lis
-rw-r--r-- 1 elm users  5370  9. Mai 10:54 files5.lis
-rw-r--r-- 1 elm users  6248  9. Mai 10:54 files6.lis
-rw-r--r-- 1 elm users   884  9. Mai 10:54 files7.lis
-rw-r--r-- 1 elm users   847  9. Mai 10:54 files8.lis
-rw-r--r-- 1 elm users   884  9. Mai 10:54 files9.lis
-rw-r--r-- 1 elm users 58170  9. Mai 10:54 files.lis

very strange!!

get the cpio:
wget_http://ftp.hosteurope.de/mirror/ftp.opensuse.org/discontinued/10.0/suse/x86_64/glibc-devel-2.3.5-40.x86_64.rpm
rpm2cpio_glibc-devel-2.3.5-40.x86_64.rpm_>glibc-devel-2.3.5-40.x86_64.cpio

attachement: full program creating files*.lis

  In general a program should not be influenced by the fact how its
output is used (whether piped to head or outputted directly). Most
likely cpio just does not handle some error condition (output file
descriptor closed by other party). However then it is perhaps a bug of
head, because head should not disrupt its pipe antecessors by closing
its file descriptor prematurely.
  Perhaps this is even a general kernel related issue occurring with the
usage of other coreutils as well, in the way that the other end of a
pipe should never panic if a consumer finishes (rather behave like
piping to /dev/zero on from the point where the filedesc is closed by
the consumer).


#!/bin/bash


unpack() {
  echo "${braun}unpacking glibc-devel cpio ....${nv}"
  cpio -idv './usr/include/*' 'usr/include/*' <glibc-devel-*.cpio
  find ./usr >files.lis
  for i in $(seq 10); do
    rm -fr ./usr
    for a in glibc-devel-*.cpio; do
      echo "${braun}  cpio -idv './usr/include/*' <address@hidden"
      cpio -idv './usr/include/*' 'usr/include/*' <$a 2>&1 | head
      # cpio | head: entpackt manchmal manche Dateien nicht
    done
    find ./usr >files$i.lis
    cmp files$i.lis files.lis || echo -n "${rot}archive not correctly unpacked 
in run #$i !!{nv}"
  done
}

{
  unpack

} 9>/dev/null
echo;echo


reply via email to

[Prev in Thread] Current Thread [Next in Thread]