From: Mike Frysinger <vapier@gentoo.org>
To: Kevin Buettner <kevinb@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] PPC sim: Don't close file descriptors 0, 1, or 2
Date: Tue, 17 Nov 2015 21:05:00 -0000 [thread overview]
Message-ID: <20151117210540.GM31395@vapier.lan> (raw)
In-Reply-To: <20151117133154.72b61a52@pinnacle.lan>
[-- Attachment #1: Type: text/plain, Size: 1386 bytes --]
On 17 Nov 2015 13:31, Kevin Buettner wrote:
> On Tue, 17 Nov 2015 00:41:33 -0500 Mike Frysinger wrote:
> > > So sim/common is doing the same thing as my proposed patch for ppc;
> > > sim/common is just using a more elegant mechanism to avoid calling
> > > close() on these three file descriptors.
> >
> > the difference is that this code sequence misbehaves after your change:
> > close(1);
> > write(1, "foo", 3);
> > under the common sim, the write will return EBADF.
> >
> > considering how much of common/ came from ppc/ i'm a little surprised
> > virtualization of the fd table didn't.
> >
> > it would be nice if we could at least hide these three fds (a static
> > array of 3 bools maybe?), but i won't push hard for you to do that.
>
> Do you mean an array which indicates the open / closed status of each
> of stdin, stdout, and stderr? This status would then be used to
> return EBADF in the right places when the descriptor is "closed".
correct. maybe add a helper func like the common code does, and then
have every wrapper (read, write, etc...) check that before making the
actual call. i don't think we have to get fancy and preserve exact
behavior since the standard does not require it; i.e. this code:
close(2)
int fd = open(...)
fd would normally be 2, but since we haven't really closed it, you'd
get back a higher fd.
-mike
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2015-11-17 21:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-16 21:58 Kevin Buettner
2015-11-16 23:53 ` Mike Frysinger
2015-11-17 4:05 ` Kevin Buettner
2015-11-17 5:41 ` Mike Frysinger
2015-11-17 20:32 ` Kevin Buettner
2015-11-17 21:05 ` Mike Frysinger [this message]
2015-12-07 20:29 ` Kevin Buettner
2015-12-30 0:18 ` Mike Frysinger
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=20151117210540.GM31395@vapier.lan \
--to=vapier@gentoo.org \
--cc=gdb-patches@sourceware.org \
--cc=kevinb@redhat.com \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).