Changes from 5.2.1 to 5.3 (theads / signal handling)
julian at elischer.org
Wed Jan 25 14:59:44 PST 2006
Jose Marcio Martins da Cruz wrote:
> Julian Elischer wrote:
>> Jose Marcio Martins da Cruz wrote:
>> a new threading library.
> Here are my compile flags :
> CPPFLAGS : only some -I and -D flags
> CFLAGS : -D_THREAD_SAFE -pthread
> LDFLAGS : -lmilter -lkvm -lm -lpthread
>> have you tried 6.0?
> Yes. It presents the same behaviour. Either way, I've found it with
> 6.0, and tried back with previous versions till find when the change
> took place.
>> also, does the child do an exec() after forking?
> No. The child gets out the father loop and calls another
> initialisation function.
The Posix spec says that after a fork(0 teh child must do almost nothing
before calling exec()
and that AT A MAXIMUM it should only call async-safe functions. (i.e.
functions that can be called from
within signal handlers).
There is all sorts of state being kept for the "now non existant"
threads in that address space.
For example, some of them will still exist if they were stopped in user
space at the time,
but some of them will not (if tehy were in the kenrel at teh time). In
the process will now be marked "non threaded" in the kernel, as it now only
has one kernel thread (as specified by posix) so an attempt to schedule
from user space will lead to unknown behaviour. The child will most likely
run for a bit and then freeze up or die in some mysterious way. ( sound
> As It seemed to me that all father's threads are stopped in the forked
> process, this seemed to me not be a problem. Am I right ?
no. Nothing has told the user half of the threading system about this.
> The signal handler thread is launched by the following sequence of
> sigaddset(&set, SIGHUP);
> sigaddset(&set, SIGTERM);
> sigaddset(&set, SIGINT);
> sigaddset(&set, SIGUSR1);
> sigaddset(&set, SIGUSR2);
> if ((r = pthread_sigmask(SIG_BLOCK, &set, NULL)) != 0)
> errno = r;
> LOG_SYS_ERROR("Couldn't mask signals");
> if ((r = pthread_create(&tid, NULL, filter_signal_handler, NULL)) != 0)
> LOG_SYS_ERROR("Error launching filter_signal_handler");
> Thanks for your help.
More information about the freebsd-threads