pthread+exec question

Damien Elmes resolve at repose.cx
Mon Feb 11 10:02:29 EST 2002


Eyal Lebedinsky <eyal at eyal.emu.id.au> writes:

> >   ``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?

[disclaimer.. i've done very little with threading]

if you want to ensure that you keep the main pid of the process (and thus avoid
falling through), the simplest way i can see of doing this is to refactor your
program to check for a flag that's set when the child thread ends, and roll the
exec behavior into the main one. this may not be a very elegant way to go about
it, but threads and process control (such as signals) have never been
particularly elegant.

-- 
Damien Elmes
resolve at repose.cx




More information about the linux mailing list