From: "vamsi krishna" <vamsi.krishnak@gmail.com>
To: "Valdis.Kletnieks@vt.edu" <Valdis.Kletnieks@vt.edu>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Quick close of all the open files.
Date: Wed, 7 Jun 2006 06:52:19 +0530 [thread overview]
Message-ID: <3faf05680606061822g25c242ddq58efdb762ca33252@mail.gmail.com> (raw)
In-Reply-To: <200606070033.k570X6Bu007481@turing-police.cc.vt.edu>
> > >
> > I checked as follows I did printf("lowest fd = %d",fileno(tmpfile()));
> > it prints 3
>
> Which proves that file descriptor 3 was closed, so tmpfile() was able to
> open it. This certainly implies that fd 0, 1, 2 (connected to stdin,
> stdout, and stderr streams of stdio) are still open, contrary to your
> statement that *all* of them are closed.
I know 0,1,2 are open (I opened it) no need to tell it specifically,
HOW DO YOU THINK I CAN PRINT SOME THING WITHOUT OPENING THIS
FILES(stdout,stderr)?
>
> If file descriptor 3 is closed, but 4 is open, what does tmpfile()
> do? Hint - tmpfile() ends up invoking open(), and the manpage for that says:
>
> Given a pathname for a file, open() returns a file descriptor, a small,
> non-negative integer for use in subsequent system calls (read(2),
> write(2), lseek(2), fcntl(2), etc.). The file descriptor returned by a
> successful call will be the lowest-numbered file descriptor not cur-
> rently open for the process.
>
> So.. explain why you think that "all files were closed"? We know that 0..2
> were open, and we know nothing about 4..1023.
>
> This doesn't look like a kernel bug, you may want to continue the discussion
> on one of the various "beginning Linux C programming" lists.
>
> On Tue, 06 Jun 2006 23:03:38 BST, =?iso-8859-1?Q?M=E5ns_Rullg=E5rd?= said:
> > > (Hint - what does that fp->_chain = stderr *really* do? ;)
> >
> > As it touches the innards of the FILE type, it invokes undefined
> > behavior. Nothing that follows can be considered a bug.
>
> Invoking undefined behavior is often considered a bug itself. And it's
> certainly happening in userspace.. so there's a userspace bug. ;)
>
>
>
next prev parent reply other threads:[~2006-06-07 1:22 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-06 21:45 vamsi krishna
2006-06-06 21:56 ` Valdis.Kletnieks
2006-06-06 22:02 ` vamsi krishna
2006-06-06 22:39 ` Måns Rullgård
2006-06-07 0:33 ` Valdis.Kletnieks
2006-06-07 1:22 ` vamsi krishna [this message]
2006-06-07 7:57 ` Måns Rullgård
2006-06-07 8:50 ` Bernd Petrovitsch
2006-06-07 7:56 ` Måns Rullgård
2006-06-06 22:03 ` Måns Rullgård
2006-06-07 11:12 ` linux-os (Dick Johnson)
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=3faf05680606061822g25c242ddq58efdb762ca33252@mail.gmail.com \
--to=vamsi.krishnak@gmail.com \
--cc=Valdis.Kletnieks@vt.edu \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®