Re: grep -Dskip doesn't skip FIFOs

2012-12-06 Thread Marco Steinbach

David Xu wrote on 06.12.2012 04:46:

On 2012/12/06 11:28, David Xu wrote:

On 2012/12/06 07:07, Marco Steinbach wrote:

Hi there,

grep(1) does not seem to skip FIFOs when told to.


snip

I think you need a patch to fix it, the bug is in ggrep, it tries to
open a FIFO before checking if it is a FIFO, then blocked.

http://people.freebsd.org/~davidxu/patch/grep.c.diff

___






or the patch:
http://people.freebsd.org/~davidxu/patch/grep.c.diff2

The patch opens file with O_NONBLOCK, then turns off O_NONBLOCK,
and only checks if a file is a FIFO in reset() function.


This patch also seems to fix it.  I can't comment on the patches 
themselves, though.


Anyway, thank you again for taking care of this.

MfG CoCo
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


grep -Dskip doesn't skip FIFOs

2012-12-05 Thread Marco Steinbach

Hi there,

grep(1) does not seem to skip FIFOs when told to.

coco@probsd:~

uname -a

FreeBSD probsd.c0c0.intra 8.3-STABLE FreeBSD 8.3-STABLE #0 r243477: Sat Nov 24 
11:07:17 CET 2012 root@x2.c0c0.intra:/usr/obj/usr/src/sys/GATEKEEPER  i386
coco@probsd:~

mkfifo bleh

coco@probsd:~

ls -l bleh

prw-r--r--  1 coco  coco  0 Dec  5 23:55 bleh
coco@probsd:~

grep -Dskip foobar bleh

^C
coco@probsd:~

truss grep -Dskip foobar bleh

__sysctl(0xbfbfe074,0x2,0xbfbfe07c,0xbfbfe080,0x0,0x0) = 0 (0x0)
mmap(0x0,336,PROT_READ|PROT_WRITE,MAP_ANON,-1,0x0) = 671711232 (0x28098000)
munmap(0x28098000,336)   = 0 (0x0)
__sysctl(0xbfbfe0d8,0x2,0x2808ee7c,0xbfbfe0e0,0x0,0x0) = 0 (0x0)
mmap(0x0,32768,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 671711232 
(0x28098000)
issetugid(0x280878ab,0xbfbfe59c,0x104,0x0,0x0,0x0) = 0 (0x0)
open(/etc/libmap.conf,O_RDONLY,0666)   ERR#2 'No such file or 
directory'
open(/var/run/ld-elf.so.hints,O_RDONLY,00) = 3 (0x3)
read(3,Ehnt\^A\0\0\0\M^@\0\0\0\M-1\0\0...,128) = 128 (0x80)
lseek(3,0x80,SEEK_SET)   = 128 (0x80)
read(3,/lib:/usr/lib:/usr/lib/compat:/u...,177) = 177 (0xb1)
close(3) = 0 (0x0)
access(/lib/libgnuregex.so.5,0)ERR#2 'No such file or 
directory'
access(/usr/lib/libgnuregex.so.5,0)= 0 (0x0)
open(/usr/lib/libgnuregex.so.5,O_RDONLY,00)= 3 (0x3)
fstat(3,{ mode=-r--r--r-- ,inode=5484738,size=64244,blksize=16384 }) = 0 (0x0)
pread(0x3,0x2808ddc0,0x1000,0x0,0x0,0x0) = 4096 (0x1000)
mmap(0x0,69632,PROT_NONE,MAP_PRIVATE|MAP_ANON|MAP_NOCORE,-1,0x0) = 671744000 
(0x280a)
mmap(0x280a,65536,PROT_READ|PROT_EXEC,MAP_PRIVATE|MAP_FIXED|MAP_NOCORE,3,0x0)
 = 671744000 (0x280a)
mmap(0x280b,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED,3,0xf000) = 
671809536 (0x280b)
close(3) = 0 (0x0)
access(/lib/libbz2.so.4,0) ERR#2 'No such file or 
directory'
access(/usr/lib/libbz2.so.4,0) = 0 (0x0)
open(/usr/lib/libbz2.so.4,O_RDONLY,027757760314) = 3 (0x3)
fstat(3,{ mode=-r--r--r-- ,inode=5484473,size=8,blksize=16384 }) = 0 (0x0)
pread(0x3,0x2808ddc0,0x1000,0x0,0x0,0x0) = 4096 (0x1000)
mmap(0x0,65536,PROT_NONE,MAP_PRIVATE|MAP_ANON|MAP_NOCORE,-1,0x0) = 671813632 
(0x280b1000)
mmap(0x280b1000,61440,PROT_READ|PROT_EXEC,MAP_PRIVATE|MAP_FIXED|MAP_NOCORE,3,0x0)
 = 671813632 (0x280b1000)
mmap(0x280c,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED,3,0xf000) = 
671875072 (0x280c)
close(3) = 0 (0x0)
access(/lib/libz.so.5,0)   = 0 (0x0)
open(/lib/libz.so.5,O_RDONLY,027757760314) = 3 (0x3)
fstat(3,{ mode=-r--r--r-- ,inode=5470199,size=72328,blksize=16384 }) = 0 (0x0)
pread(0x3,0x2808ddc0,0x1000,0x0,0x0,0x0) = 4096 (0x1000)
mmap(0x0,73728,PROT_NONE,MAP_PRIVATE|MAP_ANON|MAP_NOCORE,-1,0x0) = 671879168 
(0x280c1000)
mmap(0x280c1000,69632,PROT_READ|PROT_EXEC,MAP_PRIVATE|MAP_FIXED|MAP_NOCORE,3,0x0)
 = 671879168 (0x280c1000)
mmap(0x280d2000,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED,3,0x11000) = 
671948800 (0x280d2000)
close(3) = 0 (0x0)
access(/lib/libc.so.7,0)   = 0 (0x0)
open(/lib/libc.so.7,O_RDONLY,027757760314) = 3 (0x3)
fstat(3,{ mode=-r--r--r-- ,inode=5470167,size=1158944,blksize=16384 }) = 0 (0x0)
pread(0x3,0x2808ddc0,0x1000,0x0,0x0,0x0) = 4096 (0x1000)
mmap(0x0,1167360,PROT_NONE,MAP_PRIVATE|MAP_ANON|MAP_NOCORE,-1,0x0) = 671952896 
(0x280d3000)
mmap(0x280d3000,1048576,PROT_READ|PROT_EXEC,MAP_PRIVATE|MAP_FIXED|MAP_NOCORE,3,0x0)
 = 671952896 (0x280d3000)
mmap(0x281d3000,28672,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED,3,0xff000) = 
673001472 (0x281d3000)
mmap(0x281da000,90112,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED|MAP_ANON,-1,0x0)
 = 673030144 (0x281da000)
close(3) = 0 (0x0)
mmap(0x0,880,PROT_READ|PROT_WRITE,MAP_ANON,-1,0x0) = 673120256 (0x281f)
munmap(0x281f,880)   = 0 (0x0)
mmap(0x0,600,PROT_READ|PROT_WRITE,MAP_ANON,-1,0x0) = 673120256 (0x281f)
munmap(0x281f,600)   = 0 (0x0)
mmap(0x0,712,PROT_READ|PROT_WRITE,MAP_ANON,-1,0x0) = 673120256 (0x281f)
munmap(0x281f,712)   = 0 (0x0)
mmap(0x0,1048,PROT_READ|PROT_WRITE,MAP_ANON,-1,0x0) = 673120256 (0x281f)
munmap(0x281f,1048)  = 0 (0x0)
mmap(0x0,22000,PROT_READ|PROT_WRITE,MAP_ANON,-1,0x0) = 673120256 (0x281f)
munmap(0x281f,22000) = 0 (0x0)
sysarch(0xa,0xbfbfe140,0x2805d51b,0x2808d318,0x28070159,0x2808d318) = 0 (0x0)
sigprocmask(SIG_BLOCK,SIGHUP|SIGINT|SIGQUIT|SIGKILL|SIGPIPE|SIGALRM|SIGTERM|SIGURG|SIGSTOP|SIGTSTP|SIGCONT|SIGCHLD|SIGTTIN|SIGTTOU|SIGIO|SIGXCPU|SIGXFSZ|SIGVTALRM|SIGPROF|SIGWINCH|SIGINFO|SIGUSR1|SIGUSR2,0x0)
 = 0 (0x0)
sigprocmask(SIG_SETMASK,0x0,0x0) 

Re: grep -Dskip doesn't skip FIFOs

2012-12-05 Thread David Xu

On 2012/12/06 07:07, Marco Steinbach wrote:

Hi there,

grep(1) does not seem to skip FIFOs when told to.


snip

I think you need a patch to fix it, the bug is in ggrep, it tries to
open a FIFO before checking if it is a FIFO, then blocked.

http://people.freebsd.org/~davidxu/patch/grep.c.diff

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: grep -Dskip doesn't skip FIFOs

2012-12-05 Thread David Xu

On 2012/12/06 11:28, David Xu wrote:

On 2012/12/06 07:07, Marco Steinbach wrote:

Hi there,

grep(1) does not seem to skip FIFOs when told to.


snip

I think you need a patch to fix it, the bug is in ggrep, it tries to
open a FIFO before checking if it is a FIFO, then blocked.

http://people.freebsd.org/~davidxu/patch/grep.c.diff

___






or the patch:
http://people.freebsd.org/~davidxu/patch/grep.c.diff2

The patch opens file with O_NONBLOCK, then turns off O_NONBLOCK,
and only checks if a file is a FIFO in reset() function.



___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org