PgShmemCleanup()

Remove shared memory references

Synopsis:

void PgShmemCleanup();

Library:

ph

Description:

This function removes all shared memory references that you defined with PgShmemCreate() and PgShmemAttach(). If you created the block with PgShmemCreate(), the block is unlinked.

The Photon library uses atexit() to arrange for PgShmemCleanup() to be called when your program terminates normally. If your program terminates abnormally, it should call PgShmemCleanup() explicitly.


Note: You can't call Photon routines from a signal handler; use PtAppAddSignalProc() to register a Photon handler for the signals.

Examples:

This code fragment shows how you can use PgShmemCleanup() in a signal handler:

#include <signal.h>

PtSignalProcF_t ExitCleanup;

int ExitCleanup( int sig, void *data ) {    
    sig = sig;
    PgShmemCleanup();
    _exit( 1 );
}


main( ... ) {
    sigset_t my_signals;
    
    ...

    /* Set up the set of signals. */
    sigemptyset (&my_signals);
    
    sigaddset( &my_signals, SIGTERM );
    sigaddset( &my_signals, SIGHUP );
    sigaddset( &my_signals, SIGQUIT );
    sigaddset( &my_signals, SIGINT );
    
    /* Register the signal handler. */
    
    PtAppAddSignalProc(NULL, &my_signals, ExitCleanup, NULL);

    /* main loop */

    ...
}

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

PgShmemAttach(), PgShmemCreate(), PtAppAddSignalProc()

Interprocess Communication in the Photon Programmer's Guide

atexit(), sigaddset(), sigemptyset() in the QNX Neutrino Library Reference