On 2012-05-14, David Elliston <
david.e...@gmail.com> wrote:
> we have an application running on Solaris 11 which uses /etc/inittab entries to spawn and maintain a number of daemon processes. I know that use of /etc/inittab is deprecated in Solaris 11 but at the moment we would prefer not to have to modify our software to use SMF. However saying that we have hit an issue which may force our hand....
>
> We have inittab entries which look like this:
>
> app1:34:respawn: su - appuser -c "exec /APP/myDaemon.sh >> /APP/myDaemon.log 2>&1" > /dev/null 2>&1 0<&1
>
> When init state 3 is entered we see *two* processes associated with myDaemon:
>
> # uname -a
> SunOS host40054 5.11 11.0 sun4v sparc sun4v
>
> # ps -Af |grep myDa
> appuser 21383 21380 0 19:26:58 ? 0:00 -ksh -c exec /APP/myDaemon.sh >> /APP/myDaemon.log
> root 21380 1 0 19:26:58 ? 0:00 su - appuser -c exec /APP/myDaemon.sh >> /APP/myDaemon.log
This behaviour of "su" appears to be different from that in Solaris 10
which directly exec()s into the shell executing the given command
instead of delegating this to a fork()ed subprocess. Once you have the
latter, the inittab line no longer works as intended. Whether "su"
forks or subprocess or not was never well specified. Hence you are
relying on something which has apparently changed.
If you insist on putting something into /etc/inittab (what I do not
recommend) I suggest to use something with a well-defined semantics
that guarantees you that you do not get any additional processes
you do not want. You'll get that using Perl which is shipped with
Solaris 11. Just have a Perl script that falls down to the privileges
of appuser, and which then exec's to the to be executed command
using
open(STDOUT, ">>/APP/myDaemon.log");
exec {'/APP/myDaemon.sh'} '/APP/myDaemon.sh';
Andreas.