hastd: hooks run with masked signals

Mikolaj Golub to.my.trociny at gmail.com
Sat Oct 16 07:47:24 UTC 2010


Hi,

Main hastd process uses sigprocmask(2)/sigtimedwait(2) API. Currently when
a hook is started it inherits signal mask from the main process, so hooks are
run with SIGHUP, SIGINT, SIGTERM and SIGCHLD blocked. This is not an issue for
short living, self exiting processes but if one want to start some daemon by
hook then there is an issue with terminating it. 

Here is a hook to reproduce this:

#!/bin/sh

#DAEMON=/etc/rc.d/bsnmpd
DAEMON=/etc/rc.d/lpd

case $1 in
    start|connect)
        ${DAEMON} onestart
        ;;
    stop|disconnect)
        ${DAEMON} onestop
        ;;
    status)
        ${DAEMON} onestatus
        ;;
    role)
        exit 0
        ;;
    *)
        echo "usage: $0 stop|start|status|role|connect|disconnect"
        exit 1
        ;;
esac

And after connect event we have lpd running with SIGHUP, SIGINT, SIGTERM and
SIGCHLD blocked:

 1396 100075 lpd              HUP      -B
 1396 100075 lpd              INT      -B
 1396 100075 lpd              TERM     -B
 1396 100075 lpd              CHLD     -B

What do you think about the attached patch?

-- 
Mikolaj Golub
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hooks.c.sigprocmask.patch
Type: text/x-patch
Size: 653 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-fs/attachments/20101016/7c24394c/hooks.c.sigprocmask.bin


More information about the freebsd-fs mailing list