Add an execute action to a condition
#include <ha/ham.h> ham_action_t *ham_action_execute( ham_condition_t *chdl, const char *aname, const char *path, unsigned flags);
libham
The ham_action_execute() function adds an action (aname) to the specified condition. The action will execute an external program or command specified by path. The path parameter must contain the FULL path to the executable along with all parameters to be passed to it. If either the pathname or the arguments contain spaces that need to be passed on literally to the spawn call, they need to be quoted. As long as the subcomponents within the path arguments are quoted, using either of the following methods:
\'path with space\'
or
\"path with space\",
the following is allowed:
"\'path with space\' arg1 arg2 \"arg3 with space\"".
This would be parsed as
"path with space" -> path arg1 = arg1 arg2 = arg2 arg3 = "arg3 with space".
The command line is in turn passed onto a spawn command by the HAM to create a new process that will execute the command.
The handle (chdl) is obtained either:
or:
The action is executed when the appropriate condition is triggered.
Currently the following flags are defined:
Users can specify what will be done if an action fails. By adding action fail actions to a list associated with an action, users can determine what will be done in the case of an action failure. For every action that fails, the corresponding action fail list will be executed. Certain actions (e.g., ham_action_log() and ham_action_heartbeat_healthy()) never fail. For more details, refer to the appropriate section in the HAM API reference for the ham_action_fail_*() calls.
A valid handle to an action to a condition, or NULL if an error occurred (errno is set).
The connection to the HAM is invalid. This happens when the process that opened the connection (using ham_connect()) and the process that's calling ham_action_execute() aren't the same.
In addition to the above errors, the HAM returns any error it encounters while servicing this request.
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |