Re: OT: fork(): parent or child should run first?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2006-01-11 at 14:55 +0100, Bernd Petrovitsch wrote:
> On Wed, 2006-01-11 at 13:49 +0000, Ian Campbell wrote:
> > On Wed, 2006-01-11 at 14:25 +0100, Bernd Petrovitsch wrote:
> > > Then this leaves the race if an old pid is reused in a newly created
> > > process before the last instances of that pid is cleaned up.
> > 
> > The PID won't be available to be re-used until the signal handler has
> > called waitpid() on it?
> 
> Yes.
> But ATM the signal handler calls waitpid() and stores the pid in a
> to-be-cleaned-pids array (at time X).
> The main loop at some time in the future (say at time X+N) walks through
> the to-be-cleaned-pids array and cleans them from the active-childs
> array.

yuk... I'd say the application is a bit dumb for calling waitpid before
it is actually prepared for the pid to be reclaimed. 

A possible solution would be to also defer the waitpid until the main
loop cleanup function, perhaps flagging the entry in the child array as
not-active between the signal and that time or moving the pid from the
active to an inactive array in the signal handler.

Ian.
-- 
Ian Campbell
Current Noise: Sloth - Into The Sun

To err is human,
To purr feline.
		-- Robert Byrne

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux