Make "-D skip" option work with FIFO by opening file in non-blocking mode.
Reviewed by: jhb Tested by: delphij
This commit is contained in:
parent
f10df35fdf
commit
9ce6a82d5d
@ -304,7 +304,7 @@ reset (int fd, char const *file, struct stats *stats)
|
|||||||
if (directories == SKIP_DIRECTORIES && S_ISDIR (stats->stat.st_mode))
|
if (directories == SKIP_DIRECTORIES && S_ISDIR (stats->stat.st_mode))
|
||||||
return 0;
|
return 0;
|
||||||
#ifndef DJGPP
|
#ifndef DJGPP
|
||||||
if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode) || S_ISSOCK(stats->stat.st_mode)))
|
if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode) || S_ISSOCK(stats->stat.st_mode) || S_ISFIFO(stats->stat.st_mode)))
|
||||||
#else
|
#else
|
||||||
if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode)))
|
if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode)))
|
||||||
#endif
|
#endif
|
||||||
@ -942,6 +942,7 @@ grepfile (char const *file, struct stats *stats)
|
|||||||
int desc;
|
int desc;
|
||||||
int count;
|
int count;
|
||||||
int status;
|
int status;
|
||||||
|
int flags;
|
||||||
|
|
||||||
if (! file)
|
if (! file)
|
||||||
{
|
{
|
||||||
@ -950,7 +951,7 @@ grepfile (char const *file, struct stats *stats)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while ((desc = open (file, O_RDONLY)) < 0 && errno == EINTR)
|
while ((desc = open (file, O_RDONLY | O_NONBLOCK)) < 0 && errno == EINTR)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (desc < 0)
|
if (desc < 0)
|
||||||
@ -990,6 +991,9 @@ grepfile (char const *file, struct stats *stats)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flags = fcntl(desc, F_GETFL);
|
||||||
|
flags &= ~O_NONBLOCK;
|
||||||
|
fcntl(desc, F_SETFL, flags);
|
||||||
filename = file;
|
filename = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user