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 16:40:37 +0200
  • Message-id: <e3l0t5$lvj$1@xxxxxxxxxxxxxxxx>
Jerry Feldman wrote:

> Threads run in the context of the process. They all share the same
> global memory. Even when a thread runs in a detached state, it is
> still part of the parent process.
> As I said, file descriptors can be reused. So, if fd 14 is closed, the
> system can return it to you.

Absolutely - the system just seems to be doing it also when it isn't
closed ...

> Also, in the 2.4 kernel, the old Linux Threads, each thread had a
> separate PID where under the 2.6 kernel, you get 1 pid for the
> process. (You can force the old Linux Threads behavior though).

That's an interesting subject - I'm on 2.6.something, and generally I
see just the one process id. However, when debugging, it is quite
useful being able to attach to a process id, and "ps -eFl" will give
you some id you can use. Also when you're stracing with '-ff -f', each
thread has it's own file with an id.

/Per Jessen, Z├╝rich

< Previous Next >
List Navigation
Follow Ups