Re: OT: fork(): parent or child should run first?
From: Bernd Petrovitsch
Date: Wed Jan 11 2006 - 08:27:41 EST
On Wed, 2006-01-11 at 14:02 +0100, GÃbor LÃnÃrt wrote:
> Hello,
>
> Ok, you're absolutly right here. My problem is to find some solution and not
> to change the behaviour of fork() of course :) It's quite annoying to
> introduce some kind of IPC between parent and childs just for transferring a
> single pid_t ;-) Using exit status would be great (I would transfer "n")
> because it can be got by eg waitpid() in signal handler, however exit status
> is limited it status & 0377 which is too short range for us ;-( As a
> solution I've created a pid_t array and a counter which is filled by signal
> handler with pid_t got by waitpid() and then I use it in the main loop to do
> the cleanup in parent. Well, this is quite good, the only problem of mine
> that some kind of race condition may occur when altering/using these
> structures between the main loop and signal handler ...
Disabling signals for most of the main loop and activating them just
around the select()/poll/... is one solution to the problem.
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. But this is
probably only a theoretical problem (unless you fork() very very
often) ....
Bernd
--
Firmix Software GmbH http://www.firmix.at/
mobil: +43 664 4416156 fax: +43 1 7890849-55
Embedded Linux Development and Services
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/