public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Pipes Again -- a simple test case
@ 2016-01-04  8:03 Houder
  2016-01-04  8:52 ` Marco Atzeri
  0 siblings, 1 reply; 11+ messages in thread
From: Houder @ 2016-01-04  8:03 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-01-11 18:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-04  8:03 Pipes Again -- a simple test case Houder
2016-01-04  8:52 ` Marco Atzeri
2016-01-04  9:24   ` Houder
2016-01-08 16:13     ` Corinna Vinschen
2016-01-08 16:29       ` Houder
2016-01-08 18:44         ` Corinna Vinschen
2016-01-11 15:40           ` Corinna Vinschen
2016-01-11 15:47             ` Henri
2016-01-11 16:20               ` Corinna Vinschen
2016-01-11 16:25                 ` Henri
2016-01-11 19:48                   ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).