---
name: "sam_hc_callback_register"
section: "3"
platform: "linux"
package: "libsam-dev"
version: "3.1.9-2+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/sam_hc_callback_register"
---

# sam\_hc\_callback\_register(3)

Register health check callback

## NAME

sam\_hc\_callback\_register - Register health check callback

## SYNOPSIS

**#include \<corosync/sam.h\>**

**cs\_error\_t sam\_hc\_callback\_register (sam\_hc\_callback\_t cb);**

## DESCRIPTION

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)](/sam_hc_send/3.md)** 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 regularly 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.

## RETURN VALUE

This call return CS\_OK value if successful, otherwise and error is returned.

## ERRORS

- CS\_ERR\_BAD\_HANDLE

  SAM was not initialized and registered or health checking is in running state

- CS\_ERR\_LIBRARY

  internal library call failed. This can occur during fork() or pipe() system calls and the errno variable can be read to retrieve more information.

## SEE ALSO

[**sam\_start**(3)](/sam_start/3.md), [**sam\_stop**(3)](/sam_stop/3.md), [**sam\_hc\_send**(3)](/sam_hc_send/3.md), [**sam\_register**(3)](/sam_register/3.md),

**CS\_ERR\_TRY\_AGAIN** Resource temporarily unavailable

**CS\_ERR\_INVALID\_PARAM** Invalid argument

**CS\_ERR\_ACCESS** Permission denied

**CS\_ERR\_LIBRARY** The connection failed

**CS\_ERR\_INTERRUPT** System call interrupted by a signal

**CS\_ERR\_NOT\_SUPPORTED** The requested protocol/functionality not supported

**CS\_ERR\_MESSAGE\_ERROR** Incorrect auth message received

**CS\_ERR\_NO\_MEMORY** Not enough memory to complete the requested task
