SAM_REGISTER(3)
π SAM_REGISTER(3) β the corosync cluster engine programmer's manual, but make it cute π
okay bestie, gather round, we're doing the sam_register page and honestly? it's giving "short but load-bearing." this one lives in the Corosync Cluster Engine Programmer's Manual and it is SO important to place correctly, you'll see why. π«Ά
β¨ NAME β¨
sam_rehister β register a component for health checking π
(no, i didn't typo that, the page says sam_rehister, we respect the lore π)
πΈ SYNOPSIS πΈ
#include <corosync/sam.h>
cs_error_t sam_register (unsigned int *instance_id);
π¦ DESCRIPTION π¦
so the sam_register function is what you call to register a process for healthchecking. that's the whole vibe. π
here's the spicy part: if the recovery policy is set to SAM_RECOVERY_POLICY_RESTART and a recovery action is gonna be taken, then the brand-new process instance starts executing at the very next code line after this function is called. so like... the function returns and the new you just keeps going from there. no cap. that's why placement is everything. β¨
you can call this function only once (one and done, periodt), and SAM has to be initialized first by sam_initialize(3). no init, no register, them's the rules. π
the instance_id argument is a pointer to a value that stores the current iteration instance. if this parameter is NULL, then no instance_id is returned β and yeah, that means no instance_id will be returned. π (the page really said it twice, so i'm saying it twice, we're matching energy.)
that value starts at 0 for the first iteration instance, and it goes up by 1 every single time a recovery restart gets executed. and once it hits MAX_INT? it resets back to 0. iconic little loop behavior. π
π¨ the placement of this function is important because after it is called, the process id will change. like, your pid is NOT the same pid anymore. plan accordingly, bestie. π
and one more thing β after registration, event driven health checking is not running. so don't assume it's on just because you registered. it is not. fr fr.
π RETURN VALUE π
this call returns the CS_OK value if it's successful. otherwise an error gets returned. simple as that. π
π ERRORS π
CS_ERR_BAD_HANDLEβ health checking was not started by calling thesam_start(3)function. so like... you skipped a step, bestie. πCS_ERR_LIBRARYβ an internal library call failed. this can be one of pipe creation or fork. it's possible to get more information fromerrno. π
π SEE ALSO π
and here's the little error glossary the page keeps hanging out down here, we're keeping every single one because they're all facts and facts are sacred β¨:
CS_ERR_TRY_AGAINβ resource temporarily unavailableCS_ERR_INVALID_PARAMβ invalid argumentCS_ERR_ACCESSβ permission deniedCS_ERR_LIBRARYβ the connection failedCS_ERR_INTERRUPTβ system call interrupted by a signalCS_ERR_NOT_SUPPORTEDβ the requested protocol/functionality not supportedCS_ERR_MESSAGE_ERRORβ incorrect auth message receivedCS_ERR_NO_MEMORYβ not enough memory to complete the requested task
and that's the page!! π«Ά
cute sign-off time: this one's from the corosync Man Page, dated 12/01/2009 β and it's still out here changing pids and resetting instance_ids at MAX_INT like the main character it is. go register responsibly, bestie. πππ¦
π¦ where this page comes from
- debian bookworm: libsam-dev 3.1.7-1+deb12u2 Β· BSD-3-Clause
- debian trixie: libsam-dev 3.1.9-2+deb13u1 Β· BSD-3-Clause
- epel 9: corosynclib-devel 3.1.10-0.2.el9.1 Β· BSD-3-Clause
- fedora 43: corosynclib-devel 3.1.10-3.fc43 Β· BSD-3-Clause
- fedora 43: corosynclib-devel 3.1.10-3.fc43 Β· BSD-3-Clause
- fedora 43: corosynclib-devel 3.1.9-5.fc43 Β· BSD-3-Clause
- fedora 43: corosynclib-devel 3.1.9-5.fc43 Β· BSD-3-Clause
- fedora 44: corosynclib-devel 3.1.10-4.fc44 Β· BSD-3-Clause
- fedora 44: corosynclib-devel 3.1.10-4.fc44 Β· BSD-3-Clause
- fedora 44: corosynclib-devel 3.1.10-6.fc44 Β· BSD-3-Clause
- fedora 44: corosynclib-devel 3.1.10-6.fc44 Β· BSD-3-Clause
- nixos 26.05: corosync 3.1.9
- nixpkgs unstable: corosync 3.1.9
- opensuse-leap 16.0: corosync-devel 3.1.9-160000.4.1 Β· BSD-3-Clause
- opensuse-leap 16.0: corosync-devel 3.1.9-160000.4.1 Β· BSD-3-Clause
- opensuse-leap 16.0: corosync-devel 3.1.9-160000.4.1 Β· BSD-3-Clause
- opensuse-leap 16.0: corosync-devel 3.1.9-160000.4.1 Β· BSD-3-Clause
- ubuntu jammy: libsam-dev 3.1.6-1ubuntu1 Β· BSD-3-Clause
- ubuntu jammy: libsam-dev 3.1.6-1ubuntu1.2 Β· BSD-3-Clause
- ubuntu noble: libsam-dev 3.1.7-1ubuntu3 Β· BSD-3-Clause
- ubuntu noble: libsam-dev 3.1.7-1ubuntu3.2 Β· BSD-3-Clause
- ubuntu questing: libsam-dev 3.1.9-2ubuntu1
- ubuntu questing: libsam-dev 3.1.9-2ubuntu1.1
- ubuntu resolute: libsam-dev 3.1.9-2ubuntu3 Β· BSD-3-Clause
- ubuntu stonking: libsam-dev 3.1.10-3ubuntu1 Β· BSD-3-Clause
- Copyright (c) 2009 Red Hat, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms