Re: forking a process that has multiple threads

phil-news-nospam_at_ipal.net
Date: 08/12/03


Date: 12 Aug 2003 15:57:07 GMT

In comp.os.linux.development.system Duke Robillard <duke@io.com> wrote:
| Charles Wilkins wrote:
|
|>>Probably not, as in current Linux implementations, threads are implemented
|>>as separate processes.
|>
|> Unfortunately, to some degree, I have to disagree with this.
|>
|> I realize new threads show up in the process list, and I'll be the
|> first to say that I am a total newbie to threads, but I thought I read
|> that Linux threaded processes are not true process in the posix sense
|> ....
|> Also, If it were the case that in current Linux implementations,
|> threads are implemented as separate processes, then why do "threaded"
|> processes not overcome such limitations as max number of open file
|> descriptors per process where as fork to a true child process surely
|> does?
|
|
| The LinuxThreads library, which is the most common thing that
| produces "threads" on GNU/Linux systems, uses a Linux-specific
| system call similar to exec() called clone(). It creates neither
| processes nor threads, by the common definitions of those words.
| One of the regular posters on c.p.t refers to the things it creates
| as KSEs or "Kernel Schedulable Entities," which is as good a name
| as any...at least it's accurate.
|
| clone() allows the newly created KSE to share some resources
| the the process that called clone(). Among these resources
| are heap space, file descriptors, and signal handlers, which
| makes them look a lot like threads. Process ID isn't one of
| the things that can be shared, so these KSE's show up in the
| output of ps, making them look like processes.

But, can they be killed by that PID?

-- 
-----------------------------------------------------------------------------
| Phil Howard KA9WGN       | http://linuxhomepage.com/      http://ham.org/ |
| (first name) at ipal.net | http://phil.ipal.org/   http://ka9wgn.ham.org/ |
-----------------------------------------------------------------------------