Re: close return value (was Re: [ANNOUNCE] Ext3 vs Reiserfs benchmarks)

Elladan (elladan@eskimo.com)
Tue, 16 Jul 2002 20:00:43 -0700


On Tue, Jul 16, 2002 at 08:54:54PM -0600, Thunder from the hill wrote:
> Hi,
>
> On Tue, 16 Jul 2002, Elladan wrote:
> > Two threads share the file descriptor table.
> >
> > 1. Thread 1 performs close() on a file descriptor. close fails.
> > 2. Thread 2 performs open().
> > * 3. Thread 1 performs close() again, just to make sure.
>
> Thread 2 shouldn't be able to reuse a currently open fd. This application
> design is seriously broken.

No.

Thread 2 doesn't manage the file descriptor table, the kernel does.
Whether the kernel may re-use the descriptor or not depends on whether
the descriptor is closed or not. The kernel knows, but unless close()
behaves in a defined way, the application does not at this point. Thus,
step 3 may either be required, forbidden, or undefined.

-J
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/