Guardian Programmer's Guide

Table Of Contents
Fault-Tolerant Programming in C
Guardian Programmer’s Guide 421922-014
27 - 7
Retrieving File State Information in the Primary
Process
be open concurrently by both the primary and backup processes. The backup process
performs a backup open of a file by calling the __ns_backup_fopen function.
Before doing a backup open of a file, the backup process must obtain certain file open
state information from the primary process. The primary process obtains this
information by calling the __ns_fget_file_open_state function, then passes the
information to the backup process through interprocess communication.
The __ns_backup_fopen function does not set the file state in the backup process to
the corresponding file state in the primary process. If the primary process has
performed operations on a file before it has been backup opened, it is your
responsibility to ensure that the file state is up to date in the backup process.
Retrieving File State Information in the Primary Process
The primary process calls the __ns_fget_file_state function to get the current
state of a file. The primary process then sends the state information to the backup
process through interprocess communication. The __ns_fget_file_state function
does not handle key-position data from Enscribe files.
Updating File State Information in the Backup Process
The backup process reads from the $RECEIVE file the file state information sent by
the primary process. The backup process then calls the __ns_fset_file_state
function to update its memory with the file state information.
Terminating the Primary and Backup Processes
You can terminate the primary and backup processes by calling either the exit
function or the terminate_program function. These functions cause both the
primary and backup processes to stop when:
The calling process is executing as a Guardian (rather than OSS) process.
They are called from the primary process.
Normal termination is specified. (That is, exit(0) or
terminate_program(0,...) .)