The following code snippet shows how to begin monitoring the inetd process:
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <sys/stat.h> #include <sys/netmgr.h> #include <fcntl.h> #include <ha/ham.h> int main(int argc, char *argv[]) { int status; char *inetdpath; ham_entity_t *ehdl; ham_condition_t *chdl; ham_action_t *ahdl; int inetdpid; inetdpath = strdup("/usr/sbin/inetd -D"); inetdpid = -1; ham_connect(0); ehdl = ham_attach("inetd", ND_LOCAL_NODE, inetdpid, inetdpath, 0); if (ehdl != NULL) { chdl = ham_condition(ehdl,CONDDEATH, "death", HREARMAFTERRESTART); if (chdl != NULL) { ahdl = ham_action_restart(chdl, "restart", inetdpath, HREARMAFTERRESTART); if (ahdl == NULL) printf("add action failed\n"); } else printf("add condition failed\n"); } else printf("add entity failed\n"); ham_disconnect(0); exit(0); }