public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Why is stdin always a pipe?
@ 2018-07-20 13:17 João Eiras
  2018-07-20 14:52 ` David Macek
  0 siblings, 1 reply; 6+ messages in thread
From: João Eiras @ 2018-07-20 13:17 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-07-21  1:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-20 13:17 Why is stdin always a pipe? João Eiras
2018-07-20 14:52 ` David Macek
2018-07-20 15:12   ` João Eiras
2018-07-21  0:59     ` Brian Inglis
2018-07-21  1:59       ` Heavenly Avenger
2018-07-21  2:31         ` João Eiras

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).