This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Why is stdin always a pipe?
- From: João Eiras <joao dot eiras at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Fri, 20 Jul 2018 14:02:45 +0200
- Subject: Why is stdin always a pipe?
Hi.
I'm trying to figure out the best way to detect when my program is
being piped data.
So far I've used in linux often "[[ -p /dev/stdin ]]". During an
interactive session, /dev/stdin will be a character device, not a
pipe, and if stdin is closed ( command 0<&- ) then it's nothing.
But in cygwin, /dev/stdin is ALWAYS a pipe. So, I could use "[[ -t 0
]]" to check if stdin is a tty, but that would not cover when running
my script in a background job or service with a closed stdin.
So, a) what is the correct way to detect if stdin is being piped data
and b) is this a bug or design limitation ?
Thank you.
--
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