innwatch forks without reason

Lauri Tirkkonen ltirkkon at niksula.hut.fi
Mon Sep 15 12:31:20 UTC 2014


On Mon, Sep 15 2014 14:09:14 +0200, Julien ÉLIE wrote:
> So it seems that innwatch does not wait for the forked-off shell to
> terminate.
> 
> 
> while { sleep ${NEXTSLEEP} & CHILDPID=$! ; }
> do
>     wait
>     CHILDPID=
>     NEXTSLEEP=${INNWATCHSLEEPTIME}
> [...]

Actually I'm wrong, sorry. I messed up applying this part of the patch
because it didn't apply cleanly and I did it by hand :(

It actually does work now, when I've actually added the 'wait'... :)

    # svcs -vp inn
    STATE          NSTATE        STIME    CTID   FMRI
    online         -             15:23:43 918376 svc:/network/nntp/inn:default
                   15:23:40      598 ovdb_monitor
                   15:23:40      599 ovdb_monitor
                   15:23:40      600 ovdb_monitor
                   15:23:40      601 ovdb_monitor
                   15:23:43      604 innd
                   15:23:43      605 innwatch
                   15:23:44      622 innfeed
                   15:23:44      623 overchan
                   15:24:45     1102 innwatch

Of course the easiest way to handle all this on illumos would be to tell SMF to
just kill all the processes in the contract on stop (instead of executing
rc.news, ie. let the service system manage processes instead of relying on pid
files and shell magic), but I'm not completely confident that will do the right
thing.

There's still at least one race condition, when stopping the service
right after starting it:

    [ Sep 15 15:22:22 Executing start method ("/opt/news/bin/rc.news"). ]
    Starting ovdb.
    ovdb_init: database is quiescent, running normal recovery
    ovdb_init: starting ovdb monitor
    Starting innd.
    Scheduled start of /opt/news/bin/innwatch.
    [ Sep 15 15:22:25 Method "start" exited with status 0. ]
    [ Sep 15 15:22:25 Stopping because service disabled. ]
    [ Sep 15 15:22:25 Executing stop method ("/opt/news/bin/rc.news stop").
    ]
    Stopping innd: ctlinnd: no innd.pid file; did server die?
    ctlinnd: cannot send "shutdown" command (dead server failure): No such process

    Stopping ovdb_monitor: 
    [ Sep 15 15:22:25 Method "stop" exited with status 0. ]

> I would have liked to have code that conciliates the two behaviours
> (sleep being a builtin or not)...

Right, I guess forking works there. But it might be worth considering to
call the utility with path to be sure that a builtin isn't used.

-- 
Lauri Tirkkonen
Niksula systems specialist


More information about the inn-workers mailing list