For attaching/detaching all other entities

QNX SDP8.0High Availability Framework Developer's GuideDeveloper
ham_entity_t *ham_attach(char *ename, int reserved, pid_t pid, char *line,
              unsigned flags);
int ham_detach(ham_entity_t *ehdl, unsigned flags);
int ham_detach_name(int reserved, char *ename, unsigned flags);

These attach/detach/detach-name functions are very similar to the *_self() functions above, except here the calling process asks a HAM to monitor a different process.

This mechanism allows for arbitrary monitoring of entities that already exist and aren't compiled against the HAM API library. In fact, the entities that are being monitored needn't even be aware that they're being monitored.

You can use the ham_attach() call either to:

  • start an entity and continue to monitor it

    or:

  • begin monitoring an entity that's already running.

In the ham_attach() call, if pid is -1, then we assume that the entity isn't running. The entity is started now using line as the startup command line for it. But if pid is greater than 0, then line is ignored and the pid given is attached to as an entity. Again ename needs to be unique across all entities currently registered.

The ham_detach*() functions stop monitoring a given entity. The ham_detach() call takes as an argument the original handle returned by ham_attach(). You can also call ham_detach_name(), which uses the entity's name instead of the handle.

Note that the entity handle can also be used later to add conditions to the entity (described below).

Page updated: