Make dump's behaviour more sensible when the output file is a fifo.

Normally trewind() performs a close-open-close cycle to rewind the
tape when closing the device, but this is not ideal for fifos. We
now skip the final open-close if the output descriptor is a fifo.

PR:		bin/25474
Submitted by:	Alex Bakhtin <bakhtin@amt.ru>
MFC after:	1 week
This commit is contained in:
iedowse 2002-02-11 00:50:50 +00:00
parent d9bf8ce15b
commit 31742632b2

View File

@ -43,6 +43,7 @@ static const char rcsid[] =
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
@ -314,6 +315,7 @@ flushtape()
void
trewind()
{
struct stat sb;
int f;
int got;
@ -358,6 +360,10 @@ trewind()
return;
}
#endif
if (fstat(tapefd, &sb) == 0 && S_ISFIFO(sb.st_mode)) {
(void)close(tapefd);
return;
}
(void) close(tapefd);
while ((f = open(tape, 0)) < 0)
sleep (10);