Article View: comp.bugs.2bsd
Article #94dd exit status bug (+fix)
From: Steven M. Schultz
Date: Sun, 05 May 1991 08:04
Date: Sun, 05 May 1991 08:04
95 lines
2080 bytes
2080 bytes
File: /usr/src/bin/dd.c
Description:
When dd(1) is writing an archive to tape, and
encounters a write error or even an end of tape
mark, it returns exit status 0, which spoils error
checking in scripts and especially if it is the last
command in a list.
Repeat-By:
try it; or inspect code to see that term() always
exits with zero.
Fix:
Apply the following patch and recompile 'dd'.
*** dd.c.old Sun Feb 8 14:24:49 1987
--- dd.c Sun Mar 31 00:23:49 1991
***************
*** 313,319 ****
perror("read");
if((cflag&NERR) == 0) {
flsh();
! term();
}
ibc = 0;
for(c=0; c<ibs; c++)
--- 313,319 ----
perror("read");
if((cflag&NERR) == 0) {
flsh();
! term(1);
}
ibc = 0;
for(c=0; c<ibs; c++)
***************
*** 323,329 ****
}
if(ibc == 0 && --files<=0) {
flsh();
! term();
}
if(ibc != ibs) {
nipr++;
--- 323,329 ----
}
if(ibc == 0 && --files<=0) {
flsh();
! term(0);
}
if(ibc != ibs) {
nipr++;
***************
*** 365,371 ****
c = write(obf, obuf, obc);
if(c != obc) {
perror("write");
! term();
}
obc = 0;
}
--- 365,371 ----
c = write(obf, obuf, obc);
if(c != obc) {
perror("write");
! term(1);
}
obc = 0;
}
***************
*** 592,602 ****
null(c);
}
! term()
{
stats();
! exit(0);
}
stats()
--- 592,603 ----
null(c);
}
! term(status)
! int status;
{
stats();
! exit(status);
}
stats()
Technical Details
Message-ID:
<1991May5.080445.15466@wlbr.imsd.contel.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!mahendo!wlbr!newsShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!mahendo!wlbr!news From: sms@wlv.imsd.contel.com (Steven M. Schultz) Newsgroups: comp.bugs.2bsd Subject: dd exit status bug (+fix) Message-ID: <1991May5.080445.15466@wlbr.imsd.contel.com> Date: 5 May 91 08:04:45 GMT Sender: news@wlbr.imsd.contel.com (news) Organization: Contel Federal Systems Lines: 95 Nntp-Posting-Host: wlv.imsd.contel.com