From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22934 invoked by alias); 20 Jul 2018 14:52:20 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 22925 invoked by uid 89); 20 Jul 2018 14:52:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-6.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=H*Ad:D*ca, HContent-Transfer-Encoding:8bit X-HELO: smtp-out-so.shaw.ca Received: from smtp-out-so.shaw.ca (HELO smtp-out-so.shaw.ca) (64.59.136.138) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 20 Jul 2018 14:52:18 +0000 Received: from [192.168.1.100] ([24.64.240.204]) by shaw.ca with ESMTP id gWlTfKLWN5HxqgWlUfxNCw; Fri, 20 Jul 2018 08:52:17 -0600 Reply-To: Brian.Inglis@SystematicSw.ab.ca Subject: Re: Why is stdin always a pipe? To: cygwin@cygwin.com References: From: Brian Inglis Openpgp: preference=signencrypt Message-ID: Date: Sat, 21 Jul 2018 00:59:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2018-07/txt/msg00200.txt.bz2 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