---
name: "sam_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_register"
---

# sam\_register(3)

Register component for health checking

## NAME

sam\_rehister - Register component for health checking

## SYNOPSIS

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

**cs\_error\_t sam\_register (unsigned int \****instance\_id*);

## DESCRIPTION

The **sam\_register** function is used to register a process for healthchecking. If recovery policy is set to *SAM\_RECOVERY\_POLICY\_RESTART* and recovery action will be taken, the new process instance will begin execution at the next code line after this function is called.

This function can be called only once and SAM must be initialized by **[sam\_initialize(3)](/sam_initialize/3.md)** function.

The *instance\_id* argument is a pointer to a value storing the current iteration instance.  If this parameter is NULL, no *instance\_id* is returned. and then, no *instance\_id* will be returned. This value starts at 0 for the  first iteration instance, and increases by 1 each time a recovery restart is executed.  After reaching MAX\_INT, the instance\_id will reset to 0.

The placement of this function is important because after it is called, the process id will change.

After registration, event driven health checking is not running.

## RETURN VALUE

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

## ERRORS

- CS\_ERR\_BAD\_HANDLE

  health checking was not started by calling **[sam\_start(3)](/sam_start/3.md)** function.

- CS\_ERR\_LIBRARY

  internal library call failed. This can be one of pipe creation or fork. It's possible to get more information from errno.

## SEE ALSO

[**sam\_start**(3)](/sam_start/3.md), [**sam\_initialize**(3)](/sam_initialize/3.md), [**sam\_hc\_callback\_register**(3)](/sam_hc_callback_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
