X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:reply-to:subject:to:references:from:message-id :date:mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=iL4jwY5XpSJVY2nZ FUgaev8pGYHAJQm/gvGi6H95+zjWc0ZqLOTyuYj1a4ZfqE1f++l4po+l5nkZCTDG z0DkrSLwm9CVOZ7U279YzTBe5wgjOtLZfRc5BgCCglAR7U7qUWVjfEK5tIRvhZzu 8EtKeaQIS1wrZpn7amYlbZ0jP88= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:reply-to:subject:to:references:from:message-id :date:mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=cowt6VCvZ2KNR4Lbi0ApWy YRFW4=; b=dE1QKcEW4K9zK0nS2Rmqm5lE2VmkQ4Pt8MrAGIubXmTgBdrwf52POX U0aND6V1NS+Dw0cHxU5YWK1IHskhiFqhJ4rOoW4cnM0ty3K+P7XYXT2XTowbGgF0 2PDjfccOZOrNo8gEE0+PIQCjpkc4RzQ8XJ3Soqkyqy8gm3s0cVnwQ= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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 Reply-To: Brian DOT Inglis AT SystematicSw DOT ab DOT ca Subject: Re: Why is stdin always a pipe? To: cygwin AT cygwin DOT com References: From: Brian Inglis Openpgp: preference=signencrypt Message-ID: Date: Fri, 20 Jul 2018 08:52:15 -0600 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 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