| delorie.com/archives/browse.cgi | search |
| 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:mime-version:content-type | |
| :content-transfer-encoding:date:from:to:subject:message-id; q= | |
| dns; s=default; b=a5Ml/K7uZMMUPHmX0nUSgeGHMBR+QV4cKKmRpPpFcx/giv | |
| w+9EIoNBNwxw3aXMrTKe/VqV31Gu+9tZv4owj9Pbv4PeJ3zl7IzIBX7VfU4fVdww | |
| qPE5N6oG8I8MteXlZ3SeYVuBesJqOEpfbFL8wgSBzq8iF6xUq6NXuWq9O1IAc= | |
| 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:mime-version:content-type | |
| :content-transfer-encoding:date:from:to:subject:message-id; s= | |
| default; bh=Czt0AQChjPutsNpS015ujzbOD5Y=; b=UUDnkRSqAg0asjPZW7LL | |
| y0st6VMSSTI5X33qFqz2WhsduXHyu1P7KYlMyXoO7exIZsTDJlrn+6a03dRS7mKQ | |
| cA/Iqa1fjLwShGMuVIQWjEFE5CrBG2nAdtX8AYpiU0Q+O8MB3GYe/+zskR/fuDoK | |
| mFRLiyNl/es/JkYo4TOpVNc= | |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Id: | <cygwin.cygwin.com> |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sourceware.org/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
| 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-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 |
| MIME-Version: | 1.0 |
| Date: | Mon, 04 Jan 2016 09:03:27 +0100 |
| From: | Houder <houder AT xs4all DOT nl> |
| To: | cygwin AT cygwin DOT com |
| Subject: | Pipes Again -- a simple test case |
| Message-ID: | <0aebd09993901f3ef3ff728d162952cd@xs4all.nl> |
| X-Sender: | houder AT xs4all DOT nl (y6MmNL6PIptlWVGaBZnimw==) |
| User-Agent: | XS4ALL Webmail |
| X-IsSubscribed: | yes |
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
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |