Guardian Programmer's Guide

Table Of Contents
Fault-Tolerant Programming in C
Guardian Programmer’s Guide 421922-014
27 - 39
Creating and Starting the Backup Process
Miscellaneous Declarations
Finally, the program contains miscellaneous declarations to define the following:
A value to be returned by the PROCESS_GETPAIRINFO_ procedure, used to
determine whether the process is running as the primary or backup process.
The $RECEIVE file name.
The maximum file-name length.
The size of the process handle, and a null process handle. A process handle is
10 words long; a null process handle has all ten words set to -1.
The file number of the backup process. This number is used by the primary
process to send information to the backup.
A variable to be used by the backup process to hold the counter state value sent
by the primary process.
The declarations are as follows:
#define RECEIVE_FILENAME "$RECEIVE"
/*Maximum file name length (plus 1 to allow for null
terminator)*/
#define MAXNAMELEN 36
/*Process handle size and null process handle. A phandle is 10
words long; a null phandle has all 10 words set to -1*/
#define PHANDLESIZE 10
#define NULLPHANDLE {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}
/*Primary process attribute code for PROCESS_SETINFO_*/
#define PRIMARY_ATTRIBUTE 47
/*File number of the backup process. Used by the primary process
to send information to the backup*/
short backup_filenum;
/*Global data*/
short counter = 0;
/*Variable for use by the backup to hold the counter state
value sent by the primary*/
short counter_state;
short primary_phandle [PHANDLESIZE];
short backup_phandle [PHANDLESIZE];
Creating and Starting the Backup Process
The primary process performs several activities related to initializing the backup
process. Specifically, it starts the backup process and opens it for interprocess