Re: [patch] file(1) determine file type of stdin

2015-05-29 Thread Sebastien Marie
> On Fri, May 29, 2015 at 11:31:37PM +0100, Nicholas Marriott wrote: > > Hi > > > > We deliberately do not support FIFOs because they will block forever if > > nothing is writing and using file(1) on FIFOs seems unnecessary, the old > > file(1) had a hack to get around this with poll(2) but we're

Re: [patch] file(1) determine file type of stdin

2015-05-29 Thread Nicholas Marriott
Oops, this was wrong, sorry - try this instead: Index: file.1 === RCS file: /cvs/src/usr.bin/file/file.1,v retrieving revision 1.41 diff -u -p -r1.41 file.1 --- file.1 27 Apr 2015 11:12:49 - 1.41 +++ file.1 29 May 2

Re: [patch] file(1) determine file type of stdin

2015-05-29 Thread Nicholas Marriott
Hi We deliberately do not support FIFOs because they will block forever if nothing is writing and using file(1) on FIFOs seems unnecessary, the old file(1) had a hack to get around this with poll(2) but we're not going to do that. So I think we should only allow FIFOs for stdin where people presum

Re: [patch] file(1) determine file type of stdin

2015-05-29 Thread Sébastien Marie
On Fri, May 29, 2015 at 12:27:16PM +0100, Nicholas Marriott wrote: > Here is a slightly tweaked version of your diff. > I am not completely ok (see below) > Index: file.c > === > RCS file: /cvs/src/usr.bin/file/file.c,v > retrieving

Re: [patch] file(1) determine file type of stdin

2015-05-29 Thread Nicholas Marriott
Whoops, you're right there. I think it is a leftover, I don't think it is the right thing to do. On Fri, May 29, 2015 at 01:32:12PM +0200, S??bastien Marie wrote: > On Fri, May 29, 2015 at 12:00:36PM +0100, Nicholas Marriott wrote: > > Hi > > > > Why do you want to set O_NONBLOCK at all? > > >

Re: [patch] file(1) determine file type of stdin

2015-05-29 Thread Sébastien Marie
On Fri, May 29, 2015 at 12:00:36PM +0100, Nicholas Marriott wrote: > Hi > > Why do you want to set O_NONBLOCK at all? > > > } else { > > fd = open(argv[idx], O_RDONLY|O_NONBLOCK); > > if (fd == -1 && (errno == ENFILE || errno == EMFILE)) Becaus

Re: [patch] file(1) determine file type of stdin

2015-05-29 Thread Nicholas Marriott
Here is a slightly tweaked version of your diff. I don't think we need to set O_NONBLOCK, we don't set it for anything else. Index: file.1 === RCS file: /cvs/src/usr.bin/file/file.1,v retrieving revision 1.41 diff -u -p -r1.41 file.

Re: [patch] file(1) determine file type of stdin

2015-05-29 Thread Nicholas Marriott
Hi Why do you want to set O_NONBLOCK at all? On Fri, May 29, 2015 at 12:32:06PM +0200, S??bastien Marie wrote: > On Thu, May 28, 2015 at 11:52:22PM +0100, Nicholas Marriott wrote: > > Hi > > > > Can you make a patch against -current? Your source tree seems pretty out > > of date. > > arg, my b

Re: [patch] file(1) determine file type of stdin

2015-05-29 Thread Sébastien Marie
On Thu, May 28, 2015 at 11:52:22PM +0100, Nicholas Marriott wrote: > Hi > > Can you make a patch against -current? Your source tree seems pretty out > of date. arg, my bads. > Yes please check the return values from fcntl and fstat. I added check for fstat, but not for fcntl. The problem with

Re: [patch] file(1) determine file type of stdin

2015-05-28 Thread Nicholas Marriott
Hi Can you make a patch against -current? Your source tree seems pretty out of date. Yes please check the return values from fcntl and fstat. On Thu, May 28, 2015 at 08:37:02PM +0200, S??bastien Marie wrote: > Hi, > > It was possible, using the previous file(1) version, to determine the > fil

Re: [patch] file(1) determine file type of stdin

2015-05-28 Thread Stuart Henderson
On 2015/05/28 20:37, Sébastien Marie wrote: > file(1) in 5.5: > --- > $ echo foobar | file - > /dev/stdin: ASCII text > > after patching: > --- > $ echo foobar | file - > -: fifo (named pipe) > - should I rename "-" to "/dev/stdin" in order to have similar output >

[patch] file(1) determine file type of stdin

2015-05-28 Thread Sébastien Marie
Hi, It was possible, using the previous file(1) version, to determine the file type of stdin stream. The current version don't permit that (or I don't found how to do that). I would propose a patch in order to support '-' argument to be trait as STDIN_FILENO descriptor. file(1) in 5.5: