From: Paulo Marques <pmarques@grupopie.com>
To: yenganti pradeep <pradeepls143@yahoo.co.in>
Cc: linux-kernel@vger.kernel.org
Subject: Re: procfs question
Date: Tue, 28 Mar 2006 17:27:59 +0100 [thread overview]
Message-ID: <4429640F.8060907@grupopie.com> (raw)
In-Reply-To: <20060328153449.3321.qmail@web8409.mail.in.yahoo.com>
yenganti pradeep wrote:
> Hi,
Hi,
> I've created a new entry under /proc, to make tests.
>
> I've defined an static int var=0;
>
> Then I link my proc entry read function to a function
> that only performs this:
>
> int length;
> length=sprintf(page,"Value %d",var++);
>
> return length;
>
> But when I cat/vi the file continuosly I get:
>
> Value 0
> Value 3
> Value 6
>
> etc...
>
> Why is this three numbers increment?
'cat' will issue a read for more bytes than your function provides. As
this read isn't fully satisfied it will issue another read for the rest
at a different offset, etc. So your function gets called several times.
Just do a 'strace' on 'cat' to see what 'cat' really does. For more
details search for the thread 'procfs uglyness caused by "cat"'.
Your read function really shouldn't have side effects...
--
Paulo Marques - www.grupopie.com
Pointy-Haired Boss: I don't see anything that could stand in our way.
Dilbert: Sanity? Reality? The laws of physics?
prev parent reply other threads:[~2006-03-28 16:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-28 15:34 procfs question yenganti pradeep
2006-03-28 16:15 ` Phillip Susi
2006-03-28 16:27 ` Paulo Marques [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4429640F.8060907@grupopie.com \
--to=pmarques@grupopie.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pradeepls143@yahoo.co.in \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.