public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: [bug] Crazy I/O. -cont.
@ 1999-03-08 14:10 Michael V. Nikolaev
  1999-03-31 19:45 ` Michael V. Nikolaev
  0 siblings, 1 reply; 2+ messages in thread
From: Michael V. Nikolaev @ 1999-03-08 14:10 UTC (permalink / raw)
  To: earnie_boyd, cygwin users

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2144 bytes --]

I took a look at implementation of FILE structure in newlib/libc/include/sys/reent.h (src distribution). It contains the field -offset:

struct __sFILE {
    ...
    int    _offset;    /* current lseek offset */
    ...
};

Struct FILE typedef'ed as __sFILE. So, there exist two file offset references: one for streams, another for block I/O. I think, block I/O is based on WinAPI file I/O. Stream I/O should be built, in general, on block I/O level. And when you use lseek() the resulting file offset is not sinchronized with the file offset field in the respective stream structure (*stdin, in your case) because block I/O knows nothing about stream I/O.

Regards,

Micahel

-----Original Message-----
From: Earnie Boyd <earnie_boyd@yahoo.com>
To: Michael V. Nikolaev <mvn@gu.kiev.ua>; cygwin users <cygwin@sourceware.cygnus.com>
Date: 8 áåðåçíÿ 1999 ð. 21:45
Subject: Re: [bug] Crazy I/O.


>---"Michael V. Nikolaev" <mvn@gu.kiev.ua> wrote:
>>
>> 
>> -----Original Message-----
>> From: Earnie Boyd <earnie_boyd@yahoo.com>
>> To: cygwin users <cygwin@sourceware.cygnus.com>
>> Date: 8 áåðåçíÿ 1999 ð. 18:46
>> Subject: [bug] Crazy I/O.
>> 
>> 
>> Hi!
>> 
>> You use stdin as a _stream_ when calling gets(). So, try to call
>fseek(stdin, 0L, SEEK_SET) after the second dup2(). It should work.
>> 
>
>Didn't help.  Besides, it shouldn't be needed.
>==
>-                        \\||//
>-------------------o0O0--Earnie--0O0o-------------------
>--                earnie_boyd@yahoo.com               --
>-- http://www.freeyellow.com/members5/gw32/index.html --
>----------------------ooo0O--O0ooo----------------------
>
>PS: Newbie's, you should visit my page.
>_________________________________________________________
>DO YOU YAHOO!?
>Get your free @yahoo.com address at http://mail.yahoo.com
>
\vKCB•Ø[\b\x1d^[È\x1d[œÝXœØܚX™H\x19œ›ÛH\x1d\x1a\x1a\È^[\x1a\Ý\x0fÃB”Ù[™\b\x18H^[Y\ÜØYÙH\x1d^[È\x18ÞYÝÚ[‹][œÝXœØܚX™P\x1cÛÝ\˜Ù]Ø\™K˜ÞY۝\˘ÛÛCB

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

* Re: [bug] Crazy I/O. -cont.
  1999-03-08 14:10 [bug] Crazy I/O. -cont Michael V. Nikolaev
@ 1999-03-31 19:45 ` Michael V. Nikolaev
  0 siblings, 0 replies; 2+ messages in thread
From: Michael V. Nikolaev @ 1999-03-31 19:45 UTC (permalink / raw)
  To: earnie_boyd, cygwin users

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2144 bytes --]

I took a look at implementation of FILE structure in newlib/libc/include/sys/reent.h (src distribution). It contains the field -offset:

struct __sFILE {
    ...
    int    _offset;    /* current lseek offset */
    ...
};

Struct FILE typedef'ed as __sFILE. So, there exist two file offset references: one for streams, another for block I/O. I think, block I/O is based on WinAPI file I/O. Stream I/O should be built, in general, on block I/O level. And when you use lseek() the resulting file offset is not sinchronized with the file offset field in the respective stream structure (*stdin, in your case) because block I/O knows nothing about stream I/O.

Regards,

Micahel

-----Original Message-----
From: Earnie Boyd <earnie_boyd@yahoo.com>
To: Michael V. Nikolaev <mvn@gu.kiev.ua>; cygwin users <cygwin@sourceware.cygnus.com>
Date: 8 áåðåçíÿ 1999 ð. 21:45
Subject: Re: [bug] Crazy I/O.


>---"Michael V. Nikolaev" <mvn@gu.kiev.ua> wrote:
>>
>> 
>> -----Original Message-----
>> From: Earnie Boyd <earnie_boyd@yahoo.com>
>> To: cygwin users <cygwin@sourceware.cygnus.com>
>> Date: 8 áåðåçíÿ 1999 ð. 18:46
>> Subject: [bug] Crazy I/O.
>> 
>> 
>> Hi!
>> 
>> You use stdin as a _stream_ when calling gets(). So, try to call
>fseek(stdin, 0L, SEEK_SET) after the second dup2(). It should work.
>> 
>
>Didn't help.  Besides, it shouldn't be needed.
>==
>-                        \\||//
>-------------------o0O0--Earnie--0O0o-------------------
>--                earnie_boyd@yahoo.com               --
>-- http://www.freeyellow.com/members5/gw32/index.html --
>----------------------ooo0O--O0ooo----------------------
>
>PS: Newbie's, you should visit my page.
>_________________________________________________________
>DO YOU YAHOO!?
>Get your free @yahoo.com address at http://mail.yahoo.com
>
\vKCB•Ø[\b\x1d^[È\x1d[œÝXœØܚX™H\x19œ›ÛH\x1d\x1a\x1a\È^[\x1a\Ý\x0fÃB”Ù[™\b\x18H^[Y\ÜØYÙH\x1d^[È\x18ÞYÝÚ[‹][œÝXœØܚX™P\x1cÛÝ\˜Ù]Ø\™K˜ÞY۝\˘ÛÛCB

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

end of thread, other threads:[~1999-03-31 19:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-03-08 14:10 [bug] Crazy I/O. -cont Michael V. Nikolaev
1999-03-31 19:45 ` Michael V. Nikolaev

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).