sam_hc_callback_register(3) Register health check callback


#include <corosync/sam.h>

cs_error_t sam_hc_callback_register (sam_hc_callback_t cb);


The sam_hc_callback_register function is used to register a user provided healthcheck callback. After calling of this function, the SAM is switched from application driven healthchecking to event driven healthchecking. In this mode, sam_hc_send(3) does not need to be executed.

The parameter cb is callback function of type sam_hc_callback_t defined as:

  typedef int (*sam_hc_callback_t)(void);

This function will be regulargly called and must return 0 if the process is functioning normally, or -1 if the process is executing abnormally. When -1 is returned, the SAM server execute the registered recovery policy.

A value of NULL can be passed into this function to switch into application driven healthchecking. cb to NULL.


This call return CS_OK value if successful, otherwise and error is returned.


SAM was not initialized and registered or health checking is in running state
internal library call failed. This can occur during fork() or pipe () system calls and the errno variable can be read to retrieve more information.