pthread+exec question

Eyal Lebedinsky eyal at
Mon Feb 11 08:17:18 EST 2002

Ben Elliston wrote:
> >>>>> "Eyal" == Eyal Lebedinsky <eyal at> writes:
>   Eyal> Not really just Linux. I had the pleasure under HP/UX too. I think it
>   Eyal> is more of a basic issue. POSIX seems to say that the thread issuing
>   Eyal> the exec() is the one that continues, but POSIX says nothing about
>   Eyal> the relationship between processes and threads re pid. So doing the
>   Eyal> exec() inside a thread may terminate the original pid (as it does
>   Eyal> here) or may not (if all threads share a pid and are really
>   Eyal> lightweight).
> None of this was making any sense to me, based on my understanding of
> exec() in mt programs, so I double checked my reference (``Threads
> Primer'' by Lewis).  Without a shadow of a doubt:
>   ``The call exec() does exactly what it did before -- it deletes the
>     entire memory mapping for the calling process and replaces it with
>     the one appropriate for the new program.  A program with multiple
>     threads that calls exec() will have all of those threads (and any
>     LWPs) terminated, and the only thing left will be the new
>     program.''

Sure, this is the general way exec() should go, but the question is:
	What pid will the new program have (we may have had many pids
before)? Will the program that launched us (e.g. our terminal shell)
drop from their wait() at this point?

Eyal Lebedinsky (eyal at <>

More information about the linux mailing list