HP OpenVMS Systems

ask the wizard
Content starts here

Detached Processes, $delprc deletion, rundown?

» close window

The Question is:

 
I am running an image (C program) as detached process. It has an Exit handler
 that runs during normal image exit. But when that process gets deleted by
 STOP/ID command, I understand that the Exit handler does not get executed. So,
 is there a way or work a
round to ensure the execution of exit handler (or a clean up program) before
 process exits.
 
Thanks,
Arasu Ramalingam
 


The Answer is :

 
  It is the intent of OpenVMS that the STOP/ID command and the $delprc
  system service not invoke application exit handlers; that these commands
  cause the application and the process to exit.
 
  The most obvious, documented, and fully supported approach is the use
  of AUTHORIZE or similar tools to remove the GROUP or WORLD privilege
  from those users not sufficiently versed in the dangers of the STOP/ID
  command and the $delprc system service.
 
  Alternatively, use the $forcex system service to delete the process,
  or implement an interface (lock manager, mailbox, network, IP SNMP,
  etc) through which a management tool can request the detached process
  exit cleanly.
 
  There are several undocumented approaches for protecting processes
  against deletion or to invoke inner-mode handers, please see the
  Internals and Data Structures manual.  Alternatively, the User-Written
  System Service (UWSS) mechanism can be used to enforce the rundown
  processing.
 
  An example of using $forcex follows:
 
 
// Copyright 2003 by Hewlett-Packard Company
// Copyright 1992, 1996 by Digital Equipment Corporation
//
// Written 1-Jan-1990, by Stephen Hoffman, OpenVMS Engineering
// Various subsequent (minor) updates
//
#include <ssdef.h>
#include <starlet.h>
#include <stdio.h>
 
main( int argc, char **argv )
    {
    unsigned long int retstat;
    unsigned long int pid;
    unsigned long int finalstat = SS$_BUGCHECK;
    char hex[12];
 
    if (( argc != 2 ) && ( argc != 3 ))
        {
        printf("this is a foreign command; usage: fx pid exitstat\n");
        return SS$_BADPARAM;
        }
 
    sscanf( argv[1], "%x", &pid );
    if ( argc == 3 )
        sscanf( argv[1], "%x", &finalstat );
 
    retstat = sys$forcex( &pid, 0, finalstat );
 
    return retstat;
    }
 

answer written or last revised on ( 8-JAN-2003 )

» close window