Okay, I tried that, and smf never kills the process nor even puts it
into maintenance status. Here is the code I have:

                /* enter the maintenance mode */
                if ((fmri = getenv("SMF_FMRI")) != NULL) {
                        if (0 > smf_maintain_instance(fmri,     
                                SMF_TEMPORARY|SMF_IMMEDIATE)) {
                                        
printf("smf_maintain_instance:%s\n",scf_error());
                                exit(1);
                        }
                        /* sleep until SMF kills us */
                        while (1) {
                                pause();
                        }
                }

I originally had:
                /* enter the maintenance mode */
                if ((fmri = getenv("SMF_FMRI")) != NULL) {
                        (void) smf_maintain_instance(fmri,SMF_TEMPORARY);
                        /* sleep until SMF kills us */
                        while (1) {
                                pause();
                        }
                }

I added the rest of the code when it didn't work. Using truss, and 
pstack, I know that smf_maintain_instance is being called and returning 
zero. I also know that the process stops in the pause() call. I also 
know that the status after 2 minutes is still online and the process is
still there. Looking at what is happening under the hood in the 
smf_maintain_instance with truss, I see this:

11979/1 at 1:101.7643 -> libscf:smf_maintain_instance(0xffbfff61, 0x3, 
0xa1a04, 0x54008)
11979/1: 101.7821 issetugid()     = 0
11979/1: 101.7827 issetugid()     = 0
11979/1: 101.7839 brk(0x000752A0) = 0
11979/1: 101.7847 brk(0x000772A0) = 0
11979/1: 101.7857 open("/etc/svc/volatile/repository_door",O_RDONLY) = 6
11979/1: 101.7866 getpid()        = 11979 [1]
11979/1: 101.7875 door_call(6, 0xFFBFFAF8)      = 0
11979/1: 101.7881 close(6)                      = 0
11979/1: 101.7887 fcntl(7, F_SETFD, 0x00000001) = 0
11979/1: 101.7895 door_info(7, 0xFFBFFB70)      = 0
11979/1: 101.7900 getpid()                      = 11979 [1]
11979/1: 101.7904 getpid()                      = 11979 [1]
11979/1: 101.7910 door_call(7, 0xFFBFFA88)      = 0

The last three lines repeat 26 times, followed by:
11979/1: 101.8886 close(7)                                        = 0
11979/1 at 1:101.8903 <- libscf:smf_maintain_instance() = 0

This is the environment:

# pargs -e `pgrep xntpd`
11998:  /usr/lib/inet/xntpd
envp[0]: PATH=/usr/sbin:/usr/bin
envp[1]: SMF_FMRI=svc:/network/ntp:default
envp[2]: SMF_METHOD=/lib/svc/method/xntp
envp[3]: SMF_RESTARTER=svc:/system/svc/restarter:default
envp[4]: TZ=US/Pacific

Any ideas why this doesn't work? Is there some initialization I missed?

David Bustos wrote:
> Quoth Brian Utterback on Fri, Apr 27, 2007 at 01:32:28PM -0400:
>> The daemon in question is xntpd. If xntpd decides that the offset is
>> greater than some threshold, instead of correcting it, it prints an
>> error message and exits. The intent was that a human needs to respond
>> and decide how to fix the problem.
>>
>> That was fine up until Solaris 10. With Solaris 10 the restarter will
>> see that xntpd has exited and then re-start it. The start up method
>> runs ntpdate, which does not have the threshold and will set the clock.
>> The xntpd deamon then starts up and goes on its merry way. So, to go
>> back to the previous behavior, we want the restarter to not restart
>> xntpd. So, that's why we want to go into maintenance mode.
> 
> Ok.  You should invoke smf_maintain_instance() with SMF_TEMPORARY, and
> then sleep until SMF kills you.
> 
> 
> David

-- 
blu

"When Congress started Daylight Savings Time earlier, did
they even consider what affect an extra hour of daylight
would have on global warming? Well, did they?"
----------------------------------------------------------------------
Brian Utterback - Solaris RPE, Sun Microsystems, Inc.
Ph:877-259-7345, Em:brian.utterback-at-ess-you-enn-dot-kom

Reply via email to