NAME

cat_onclose - install callback for session closing

SYNOPSIS

#include <cat.h>

int cat_onclose(cat_session *sess, cat_closefunc *func, void *data);

DESCRIPTION

Installs a callback to be called when a session is closed. The callback func is invoked with sess and data as arguments when the session is closed with a call to cat_close().

The callback should match the following prototype:

  typedef void cat_closefunc(cat_session *, void *);

When the callback is invoked, the only cat function that can safely be called is cat_getsessid().

Any number of callbacks can be installed for a session.

The function returns CAT_OK if successful, or a negative error code otherwise.

NOTES

When running in forking mode on UNIX, sessions will be closed as part of the cleanup procedure in the child process.

SEE ALSO

cat, cat_close, cat_getsessid