From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 111529 invoked by alias); 22 Jan 2019 08:50:06 -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 111521 invoked by uid 89); 22 Jan 2019 08:50:05 -0000 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 Received: from lb3-smtp-cloud8.xs4all.net (HELO lb3-smtp-cloud8.xs4all.net) (194.109.24.29) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 22 Jan 2019 08:50:03 +0000 Received: from tmp.L4W75gdNkK ([83.162.234.136]) by smtp-cloud8.xs4all.net with ESMTPSA id lrkrgDSGlNR5ylrksgg26T; Tue, 22 Jan 2019 09:50:00 +0100 Date: Tue, 22 Jan 2019 08:50:00 -0000 Message-ID: From: Houder Reply-To: cygwin@cygwin.com To: cygwin@cygwin.com Subject: Re: /dev/fd/N not synonymous with file descriptor N; it is on Linux References: <0f030e809f063f5a5e64ff7a7a0c3227@xs4all.nl> <20190106201950.GC4430@calimero.vinschen.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 X-SW-Source: 2019-01/txt/msg00164.txt.bz2 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