/****** rsbx.lib/EmptyMorgue() ***********************************************
*
*   NAME
*	EmptyMorgue -- Process child termination messages.
*
*   SYNOPSIS
*	EmptyMorgue()
*
*	void EmptyMorgue( void );
*
*   FUNCTION
*	This function processes any termination messages from child processes
*	    of this process.
*
*   INPUTS
*
*   RESULT
*
*   NOTES
*
*   SEE ALSO
*	ChildStatus(), CreateFamily(), LaunchChildl(), LaunchChildv(),
*	OrphanChild(), OrphanChildren(), WaitChild().
*
*   BUGS
*	None Known.
*
******************************************************************************
*
*/

#include <rsbx/childtasking.h>

void EmptyMorgue( void )
	{
	struct DeathNotice *msg;
	struct ChildNode *node;

	while (msg = (struct DeathNotice *)GetMsg(_Children->Morgue))
		{
		for (node = (struct ChildNode *)_Children->ChildList.mlh_Head;
			node->node.mln_Succ;
			node = (struct ChildNode *)node->node.mln_Succ)
			{
			if (&node->notice == msg)
				{
				msg->noticeptr = NULL;
				break;
				}
			}

		if (!node->node.mln_Succ)
			{
			ReplyMsg((struct Message *)msg);
			}
		}
	}
