dd exit status bug (+fix)
Steven M. Schultz
sms at wlv.imsd.contel.com
Sun May 5 18:04:45 AEST 1991
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()
More information about the Comp.bugs.2bsd
mailing list