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