Why is stdin always a pipe?

Brian Inglis Brian.Inglis@SystematicSw.ab.ca
Sat Jul 21 00:59:00 GMT 2018


On 2018-07-20 07:17, João Eiras wrote:
>>> $ [[ -p /dev/stdin ]] && echo pipe || echo nopipe
>>> nopipe
> 
> Interesting, it's always a pipe for me. What about ls ?
> 
> $ ls -l /dev/stdin
> prw------- 1 user None 0 Jun  4 15:54 /dev/stdin

Are you using a terminal that does not provide a console interface?
That is a pipe; Cygwin terms look like this:

$ ll -go /dev/std*; ll -go /proc/self/fd/[012]; ll -go /dev/pty?
lrwxrwxrwx 1 15 May 14  2013 /dev/stderr -> /proc/self/fd/2
lrwxrwxrwx 1 15 May 14  2013 /dev/stdin -> /proc/self/fd/0
lrwxrwxrwx 1 15 May 14  2013 /dev/stdout -> /proc/self/fd/1
lrwxrwxrwx 1 0 Jul 20 08:18 /proc/self/fd/0 -> /dev/pty0
lrwxrwxrwx 1 0 Jul 20 08:18 /proc/self/fd/1 -> /dev/pty0
lrwxrwxrwx 1 0 Jul 20 08:18 /proc/self/fd/2 -> /dev/pty0
crw--w---- 1 136, 0 Jul 20 08:18 /dev/pty0
crw--w---- 1 136, 1 Jul 20 08:18 /dev/pty1
$ for fd in 0 1 2 3; do test -t $fd; echo fd $fd term $?; done
fd 0 term 0
fd 1 term 0
fd 2 term 0
fd 3 term 1
$ for f in /dev/{std*,pty?}; do test -p $f; echo file $f pipe $?; done
file /dev/stderr pipe 1
file /dev/stdin pipe 1
file /dev/stdout pipe 1
file /dev/pty0 pipe 1
file /dev/pty1 pipe 1

where ptys are terms and are not pipes.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list