ToolTalk User's Guide

Can a process send a request to itself?

Yes. A process can send a request that gets handled by itself. A typical pattern for this type of request is:

{	...
	tt_message_arg_val_set(m, 1, "answer");
	tt_message_reply(m);
	tt_message_destroy(m);
	return TT_CALLBACK_PROCESSED;
}

However, in the case where the handler and the sender are the same process, the message has already been destroyed when the reply comes back (to the same process). Any messages (such as callbacks or user data) attached to the message by the sender are also destroyed. To avoid this situation, do not destroy the message; for example:

{	...
	if (0!=strcmp(tt_message_sender(m),tt_default_procid())) {
		tt_message_destroy(m);
}