[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Should we use _malloc_prefork and _malloc_postfork?
>>> I think we should go one step further than using them, and override
>>> fork() in libpthread [...]
>> I'd much rather try to solve it more generally. Perhaps atfork(),
>> akin to atexit()? Or some linker magic so that each library wraps
>> (in the "ld --wrap" sense) the next's definition of (in this case)
> See the fine man page: pthread_atfork(3), posix specified even. (For
> non-threaded, that isn't available [...].)
And it is therefore useless for non-pthread-using (which is not the
same as non-threaded) programs.
Did you read my first paragraph? It pointed out that there is a
problem as soon as some other library wants to do something for fork().
This is not a threading-specific issue, in general; only this
particular instance of it is threading-specific.
> ([...], but threads are the root of all these problems.)
Threads are at the root of all the problems at immediate hand. They
are not at the root of every possible reason to want to wrap fork() in
something. For example, consider a library which wants to flush
internal buffers before fork(). Or something which wants to update an
internally-cached "current PID" value post-fork(). (I've had to deal
with each situation, but so far only within an application. Attempting
to pull the relevant code out into a library for reuse would demand
some kind of resolution, and currently the only resolution available is
to push it upstairs to the library's caller.)
But, if you really can't see past the threads to the more general
issue, by all means solve the immediate problem, then solve the next
immediate problem in a different idiosyncratic way, until you have a
half-dozen solutions to particular manifestations of a common problem.
It's no skin off my nose either way, after all.
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML mouse%rodents-montreal.org@localhost
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
Main Index |
Thread Index |