Mailinglist Archive: opensuse-programming (51 mails)

< Previous Next >
Re: [suse-programming-e] threads and file descriptors
  • From: Per Jessen <per@xxxxxxxxxxxx>
  • Date: Sun, 07 May 2006 15:19:21 +0200
  • Message-id: <e3ks4p$lg6$1@xxxxxxxxxxxxxxxx>
Jerry Feldman wrote:

> I have done quite a bit of this type of programming in the past.
> There should be NO duplication of file descriptors, but the system
> will reuse file descriptors.

Yep, that I expected.

> One of the types of programs I used to write a few years ago was where
> I would spawn the maximum number of threads, and each thread would
> open and write to the same file using locking.

In my case the threads are running completely independent of oneanother,
except for the sharing of various system resources.

> In other words, open(2) (and socket(2), accept(2)) should
> NEVER return a file descriptor of an already open file.

Yeah, I was expecting that too, but that is nonetheless what seems to be
happening. Not just from the trace I published, but also input-files
ending being truncated because the file descriptor has been reopened
for output.


/Per Jessen, Zürich


< Previous Next >
List Navigation
Follow Ups