2 * support/include/ha-callout.h
4 * High Availability NFS Callout support routines
6 * Copyright (c) 2004, Paul Clements, SteelEye Technology
8 * In order to implement HA NFS, we need several callouts at key
9 * points in statd and mountd. These callouts all come to ha_callout(),
10 * which, in turn, calls out to an ha-callout script (not part of nfs-utils;
11 * defined by -H argument to rpc.statd and rpc.mountd).
19 extern char *ha_callout_prog;
22 ha_callout(char *event, char *arg1, char *arg2, int arg3)
24 char buf[16]; /* should be plenty */
27 struct sigaction oldact, newact;
29 if (!ha_callout_prog) /* HA callout is not enabled */
32 sprintf(buf, "%d", arg3);
34 /* many daemons ignore SIGCHLD as tcpwrappers will
35 * fork a child to do logging. We need to wait
36 * for a child here, so we need to un-ignore
39 newact.sa_handler = SIG_DFL;
41 sigemptyset(&newact.sa_mask);
42 sigaction(SIGCHLD, &newact, &oldact);
45 case 0: execl(ha_callout_prog, ha_callout_prog,
47 arg3 < 0 ? NULL : buf,
51 case -1: perror("fork");
53 default: pid = waitpid(pid, &ret, 0);
55 sigaction(SIGCHLD, &oldact, &newact);
57 dprintf(N_DEBUG, "ha callout returned %d\n", WEXITSTATUS(ret));
59 xlog(D_GENERAL, "ha callout returned %d\n", WEXITSTATUS(ret));