This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PPC sim: Don't close file descriptors 0, 1, or 2

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:
	int fd = open(...)
fd would normally be 2, but since we haven't really closed it, you'd
get back a higher fd.

Attachment: signature.asc
Description: Digital signature

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]