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:date:message-id:from:reply-to:to:subject :references:in-reply-to:content-type; q=dns; s=default; b=L72JF8 0f4l0C4CHOQaRlEbu6a011czPp8nnCrglxPJNmAVi6aHYv1zTEhoOVeae+aL5o8e lBvowGN7SMpwge3YwRPuJYAsDcvik7pNzftCPlr5iLIqdgWK8Po2Pb+mdA2Lsr6z 1eiVeJt7VUTSLQ7/0rrzjiPAZBbpLq7Wtd7Bc= 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:date:message-id:from:reply-to:to:subject :references:in-reply-to:content-type; s=default; bh=SKprUnAJMPF7 oaPnkABD3kpk35U=; b=b+9HvFAnhUC3xwA0frXZQcqCZItL6nwOzkXvKK/HMq8I aII6Z67M6RvYNCf3zH+7FtxJRwK55UO7QNJoeDAYcDhxQ6HzjiYk+hTWvpeWReIP BwGGQ2U7t0fNJ/QTNnB7bkVhgwzto4WkD1Q5v/TZzxW6RhQPBCC4409an9DZjSY= 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=-0.7 required=5.0 tests=BAYES_20,NORMAL_HTTP_TO_IP,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=birth, Birth, D*@, ls X-HELO: lb3-smtp-cloud8.xs4all.net Date: Tue, 22 Jan 2019 09:50:00 +0100 Message-ID: From: Houder Reply-To: cygwin AT cygwin DOT com To: cygwin AT cygwin DOT com Subject: Re: /dev/fd/N not synonymous with file descriptor N; it is on Linux References: <0f030e809f063f5a5e64ff7a7a0c3227 AT xs4all DOT nl> <20190106201950 DOT GC4430 AT calimero DOT vinschen DOT de> In-Reply-to: <20190106201950.GC4430@calimero.vinschen.de> Content-Type: text/plain; charset=UTF-8; format=fixed User-Agent: mua.awk 0.99 X-IsSubscribed: yes On Sun, 6 Jan 2019 21:19:50, Corinna Vinschen wrote: > > On Dec 16 17:31, Houder wrote: > > L.S., > > > > /dev/fd/N not synonymous with file descriptor N; it is on Linux > > > > 64-@@ cat /dev/fd/0 <<\EOF > > > Hi > > > EOF > > cat: /dev/fd/0: No such file or directory > > > > fails on Cygwin; not on Linux. > > > > Also see: > > > > https://cygwin.com/ml/cygwin/2018-12/msg00028.html > > ( Bash heredoc on FD 3 ) > > > > Based on the output of strace on Linux, I composed an STC, that duplicates > > the steps taken by bash (and cat). > > This should work in the latest developer snapshot uploaded to > https://cygwin.com/snapshots/ Please give it a try. > > Thanks, > Corinna Nice! This solves: -i /dev/fd/N N< aap.txt 64-@@ tail -f aap.txt aap .. in another terminal 64-@@ ls -l /proc/4120/fd # 4120 is the procid of "tail" total 0 lrwxrwxrwx 1 Henri None 0 Jan 22 09:25 0 -> /dev/pty1 lrwxrwxrwx 1 Henri None 0 Jan 22 09:25 1 -> /dev/pty1 lrwxrwxrwx 1 Henri None 0 Jan 22 09:25 2 -> /dev/pty1 lrwxrwxrwx 1 Henri None 0 Jan 22 09:25 3 -> /home/Henri/redirect/aap.txt 64-@@ stat -L /proc/4120/fd/3 # shows a file of 4 bytes ... File: /proc/4120/fd/3 Size: 4 Blocks: 1 IO Block: 65536 regular file Device: 33d91880h/869865600d Inode: 35747322042382612 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 1000/ Henri) Gid: ( 513/ None) Access: 2019-01-22 09:24:41.978178200 +0100 Modify: 2019-01-22 09:24:41.978178200 +0100 Change: 2019-01-22 09:24:41.978178200 +0100 Birth: 2019-01-22 09:24:41.978178200 +0100 64-@@ rm aap.txt # hacker removing the logfile 64-@@ stat -L /proc/4120/fd/3 File: /proc/4120/fd/3 Size: 4 Blocks: 1 IO Block: 65536 regular file Device: 33d91880h/869865600d Inode: 35747322042382612 Links: 0 Access: (0644/-rw-r--r--) Uid: ( 1000/ Henri) Gid: ( 513/ None) Access: 2019-01-22 09:24:41.978178200 +0100 Modify: 2019-01-22 09:24:41.978178200 +0100 Change: 2019-01-22 09:26:25.021040800 +0100 Birth: 2019-01-22 09:24:41.978178200 +0100 64-@@ cp /proc/4120/fd/3 noot.txt # logfile rescue 64-@@ cat noot.txt # empty! (however, this works on Linux) 64-@@ cat /proc/4120/fd/3 # indeed, does not show contents 64-@@ ===== -- 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