Set up a condition to be triggered when a certain event occurs
#include <ha/ham.h> ham_condition_t *ham_condition(ham_entity_t *ehdl, int type, const char *cname, unsigned flags);
libham
You call this function to set up a condition that will be triggered when a significant event occurs.
Each entity can be associated with several different conditions, and associated with each of these conditions is a set of actions that will be performed in FIFO sequence when the condition is true. If an entity has multiple conditions that are true simultaneously, with different sets of actions associated with each condition, then all the actions associated with each condition are performed, in sequence.
This mechanism lets you combine actions together into sets and choose to remove/control them as a single “group” instead of as individual items.
The ehdl argument is an entity handle obtained either:
or:
Since conditions are associated with entities, the entity handle (ehdl) must be available before you can add conditions.
You can specify any of the following for type:
An entity's death is detected for all processes in session 1, for processes that terminate abnormally (typically due to the delivery of a signal), and for processes that are attached as self-attached entities.
The cname argument is the condition name. It must be unique across all conditions in the given entity.
When a condition is triggered, all actions defined in all conditions of the given type are executed. When an entity dies, a condition of type HCONDDEATH is triggered, and all actions in all conditions that match this type are executed.
Currently the following flags are defined:
You must call the ham_connect() function before the first call to ham_condition() in a process. If a process calls ham_connect() and then calls fork(), the child process must call ham_connect() again before it can successfully call ham_condition() in order to add conditions. |
A valid handle to a condition in the given entity; otherwise, NULL (and 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_condition() 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 |
ham_attach(), ham_attach_self(), ham_condition_remove(), ham_connect(), ham_entity_handle()