From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6956 invoked by alias); 20 Jul 2018 12:03:29 -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 6945 invoked by uid 89); 20 Jul 2018 12:03:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:645 X-HELO: mail-oi0-f44.google.com Received: from mail-oi0-f44.google.com (HELO mail-oi0-f44.google.com) (209.85.218.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 20 Jul 2018 12:03:28 +0000 Received: by mail-oi0-f44.google.com with SMTP id l10-v6so20909127oii.0 for ; Fri, 20 Jul 2018 05:03:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=HpeeFJ06tv/93+er1gYczaJyOqHoUZWQXZgzl1z9pMQ=; b=a3E4+CAVCn1qVWPw+E4SM+alAOW3yJIvEZwchgHLHLLrnDJTrglADdW1AuuES0ktby cW8oA9c16cRbWoCzcukArHC03H5Obw12IDdGAydu55Q+2D2QN3/Y/2/GrGgQGbZzzAwL SOuA+M0BNCSIuVCwhRSsoPk7aw5T6+LaEYzLdca0vHokrh+xAXkUnuu2vhEPuq8yX/ZE C6atFKa+BlPNwz3Be2Iv9hORCvP7FNb7mh5Itn1uSzBbk4aCGwhgp/oaNEkeWpeljYTd K4CZOxbgcMon55QTaE4bTTM+aHD4r2a9nr4zV162B52Xr7pDwsE6oCb2JVpgzUYK2PCl iv+g== MIME-Version: 1.0 Received: by 2002:a9d:507:0:0:0:0:0 with HTTP; Fri, 20 Jul 2018 05:02:45 -0700 (PDT) From: =?UTF-8?Q?Jo=C3=A3o_Eiras?= Date: Fri, 20 Jul 2018 13:17:00 -0000 Message-ID: Subject: Why is stdin always a pipe? To: cygwin@cygwin.com Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-07/txt/msg00195.txt.bz2 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