From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 55181 invoked by alias); 4 Jan 2016 08:03:35 -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 55170 invoked by uid 89); 4 Jan 2016 08:03:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=prof, stc, Hx-languages-length:2775, H*UA:Webmail X-HELO: lb3-smtp-cloud6.xs4all.net Received: from lb3-smtp-cloud6.xs4all.net (HELO lb3-smtp-cloud6.xs4all.net) (194.109.24.31) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 04 Jan 2016 08:03:32 +0000 Received: from webmail.xs4all.nl ([194.109.20.215]) by smtp-cloud6.xs4all.net with ESMTP id 1k3T1s00H4eRkWy01k3Ttj; Mon, 04 Jan 2016 09:03:28 +0100 Received: from a83-162-234-136.adsl.xs4all.nl ([83.162.234.136]) by webmail.xs4all.nl with HTTP (HTTP/1.1 POST); Mon, 04 Jan 2016 09:03:27 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 04 Jan 2016 08:03:00 -0000 From: Houder To: cygwin@cygwin.com Subject: Pipes Again -- a simple test case Message-ID: <0aebd09993901f3ef3ff728d162952cd@xs4all.nl> X-Sender: houder@xs4all.nl (y6MmNL6PIptlWVGaBZnimw==) User-Agent: XS4ALL Webmail X-IsSubscribed: yes X-SW-Source: 2016-01/txt/msg00017.txt.bz2 Hi Corinna, I have been looking for an STC to show why cmp fails on Cygwin (and to show the difference between Cygwin and Linux). The STC below creates a pipe (pipe() is used), followed by calls to fstat() and stat() for both the read end and the write end of the pipe. (I also tested with popen()/pclose(): same result) Regards, Henri Btw, I am using W7 prof.; Cygwin-32 and Cygwin-64; 2.3.1 and 2.4.0 ===== The code for the STC is basically as follows: int main() { struct stat sb[2]; int pfd[2]; pid_t pid = getpid(); if (pipe(pfd) != 0) errExit("pipe"); for (int f = 0; f < 2; f++) // step over the read end and write end of the pipe { char symlnk[64]; if (sprintf(symlnk, "/proc/%d/fd/%d", pid, pfd[0 + f]) <= 0) errExit("sprintf"); !f ? printf("... %s (symbolic link to the read end of the pipe)\n", symlnk) : printf("... %s (symbolic link to the write end of the pipe)\n", symlnk); printf("... using stat()\n"); if (stat(symlnk, sb) != 0) errExit("stat"); displayStatInfo(sb); printf("... using fstat()\n"); if ( fstat(pfd[0 + f], sb + 1) != 0 ) errExit("fstat"); displayStatInfo(sb + 1); } exit(EXIT_SUCCESS); } Linux shows: @@ ./t_stat2 ... /proc/968/fd/3 (symbolic link to the read end of the pipe) ... using stat() File type: FIFO or pipe Device containing i-node: (8) major=0 minor=8 I-node number: 53bc - decimal: 21436 File size: 0 bytes ... using stat() File type: FIFO or pipe Device containing i-node: (8) major=0 minor=8 I-node number: 53bc - decimal: 21436 File size: 0 bytes ... /proc/968/fd/4 (symbolic link to the write end of the pipe) ... using stat() File type: FIFO or pipe Device containing i-node: (8) major=0 minor=8 I-node number: 53bc - decimal: 21436 File size: 0 bytes ... using stat() File type: FIFO or pipe Device containing i-node: (8) major=0 minor=8 I-node number: 53bc - decimal: 21436 File size: 0 bytes Cygwin shows: @@ ./t_stat2 ... /proc/2864/fd/3 (symbolic link to the read end of the pipe) ... using stat() File type: FIFO or pipe Device containing i-node: (c7) major=0 minor=199 I-node number: a325e1ba495b63cf - decimal: 11756050592531440591 File size: 0 bytes ... using fstat() File type: FIFO or pipe Device containing i-node: (c6) major=0 minor=198 I-node number: 0 - decimal: 0 <==== zero, the non-existing i-node ... File size: 0 bytes ... /proc/2864/fd/4 (symbolic link to the write end of the pipe) ... using stat() File type: FIFO or pipe Device containing i-node: (c7) major=0 minor=199 I-node number: a325e1ba495f64cb - decimal: 11756050592531702987 <==== Linux shows the same i-node File size: 0 bytes ... using fstat() File type: FIFO or pipe Device containing i-node: (c5) major=0 minor=197 I-node number: 0 - decimal: 0 <==== ditto File size: 0 bytes ===== -- 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