On Tue, Jan 06, 2009 at 05:02:26PM +0100, Casper.Dik at Sun.COM wrote: > ( # note: parenthesis > your script here > > ) & # note: another one and &
What Casper said. The service comes online when the start method process started by svc.startd exits with SMF_EXIT_OK (0). Which means that if you have a long-running service written in shell then you need to fork a background process to run that service. One obvious way to do it is with a backgrounded sub-shell -- exactly what Casper proposes you do. In the event that you should need the parent process to wait for the child to be ready you could use a named pipe to pass an "I'm ready" message from the child to the parent: trap "rm -f \$pipe; rmdir \$pdir" EXIT pdir=$(mktemp -d -t fooXXXX) pipe=$pdir/ready-pipe if [[ -z "$pdir" ]] then print -u2 "Failed to create temp directory" exit $SMF_EXIT_ERR_FATAL fi if ! mknod $pipe p then print -u2 "Failed to create temp named pipe" exit $SMF_EXIT_ERR_FATAL fi ( # This is the child process # Initialization ... # Tell parent the service is ready if $everything_is_ok then print "$SMF_EXIT_OK" > $pipe else print "$SMF_EXIT_ERR_FATAL" > $pipe exit 1 fi # Provide service ... ) & read status < $pipe # If we couldn't read from the pipe then assume SMF_EXIT_ERR_FATAL exit ${status:-$SMF_EXIT_ERR_FATAL} Hmmm, the above could be wrapped into a ksh93 SMF library. Developers would have to provide two functions: one to initialize the service, one to provide it. Roland would like such a thing, methinks! :) Nico --