Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

I/O in C99

93 views
Skip to first unread message

Seima

unread,
Mar 19, 2012, 2:41:16 PM3/19/12
to
Hi,

Does C99 strictly require blocking I/O?

Can readers of this forum point to the section
in the C99 specification which state the rules
regarding I/O?

Sincerely,
Seima Rao.
--
comp.lang.c.moderated - moderation address: cl...@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.

Barry Schwarz

unread,
Mar 19, 2012, 6:56:24 PM3/19/12
to
On Mon, 19 Mar 2012 13:41:16 -0500 (CDT), Seima <seim...@gmail.com>
wrote:

>Hi,
>
> Does C99 strictly require blocking I/O?
>
> Can readers of this forum point to the section
> in the C99 specification which state the rules
> regarding I/O?

What do you mean by blocking I/O?

A free copy of the C99 standard can be found by googling n1256.
Section 7.19 covers I/O.

The C99 standard has been, or soon will be, replaced by the C11
standard but neither have achieved commercial popularity. Most
compilers are at the C90 level with some of the additional features of
the newer standards.

--
Remove del for email

Keith Thompson

unread,
Mar 25, 2012, 10:43:08 PM3/25/12
to
Barry Schwarz <schw...@dqel.com> writes:
> On Mon, 19 Mar 2012 13:41:16 -0500 (CDT), Seima <seim...@gmail.com>
> wrote:
>> Does C99 strictly require blocking I/O?
>>
>> Can readers of this forum point to the section
>> in the C99 specification which state the rules
>> regarding I/O?
>
> What do you mean by blocking I/O?
>
> A free copy of the C99 standard can be found by googling n1256.
> Section 7.19 covers I/O.
>
> The C99 standard has been, or soon will be, replaced by the C11
> standard but neither have achieved commercial popularity. Most
> compilers are at the C90 level with some of the additional features of
> the newer standards.

C11 is the current official standard, superseding C99. As far as I know
there hasn't been enough time for any implementation to fully support it
(or partially for that matter).

The latest draft of the C99 standard, incorporating the three Technical
Corrigenda, is at
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf

The latest freely available draft of the C11 standard, issued before the
final standard was published, is at
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf

--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

Jasen Betts

unread,
Mar 25, 2012, 10:43:39 PM3/25/12
to
On 2012-03-19, Seima <seim...@gmail.com> wrote:
> Hi,
>
> Does C99 strictly require blocking I/O?

7.19.7.1 requires fgetc return either EOF or a character,
there is no room for non-blocking reads there.

7.19.8.1 allows fread to return less than nmemb when
and error or end of file is encountered, ( but it doesn't
say "only when")

> Can readers of this forum point to the section
> in the C99 specification which state the rules
> regarding I/O?

7.19.something I expect.

in any case trying to use stdio functions for non-blocking
IO is unlikely to work well.

--
⚂⚃ 100% natural

--- Posted via news://freenews.netfront.net/ - Complaints to ne...@netfront.net ---

Thomas Richter

unread,
Mar 25, 2012, 10:44:39 PM3/25/12
to
On 19.03.2012 19:41, Seima wrote:
> Hi,
>
> Does C99 strictly require blocking I/O?

This is a strange way to ask the question. C99 strictly
requires the presence of functions like fread and fwrite that,
when given a buffer, a number of elements and element sizes, read or
write these elements to a FILE. This implies that when the functions
return the FILE somehow logically reflects these changes, and, when
reading, the input buffer is updated. In reality, a write will usually
go to a buffer first and hence will not block unnecessary, and a read
will read from a buffer and will not block unnecessary. However, such
changes will reflect in an update of internal structures that provide a
consistent view on the FILE.

What C99 does not have to offer are functions that request and IO
operation and return *before* any logical change has made to the file,
and/or before the buffer has been updated or used. POSIX does, though by
slightly different mechanisms.

> Can readers of this forum point to the section
> in the C99 specification which state the rules
> regarding I/O?

Has already been answered.
0 new messages