/****** rsbx.lib/OrphanChildren() ********************************************
*
*   NAME
*	OrphanChildren -- Orphan all child processes of this process.
*
*   SYNOPSIS
*	OrphanChildren()
*
*	void OrphanChildren( void );
*
*   FUNCTION
*	This function orphans all child processes of this process and frees
*	    the memory used to keep track of the children.
*
*   INPUTS
*
*   RESULT
*
*   NOTES
*
*   SEE ALSO
*	ChildStatus(), CreateFamily(), EmptyMorgue(), LaunchChildl(),
*	LaunchChildv(), OrphanChild(), WaitChild().
*
*   BUGS
*	None Known.
*
******************************************************************************
*
*/

#include <rsbx/childtasking.h>

void OrphanChildren( void )
	{
	struct ChildNode *node;

	Forbid();
	EmptyMorgue();
	DeletePort(_Children->Morgue);

	while ((node = (struct ChildNode *)_Children->ChildList.mlh_Head) &&
		node->node.mln_Succ)
		{
		if (node->notice.noticeptr)
			{
			*node->notice.noticeptr = NULL;
			}
		Remove((struct Node *)node);
		FreeMem(node, sizeof(struct ChildNode));
		}

	FreeMem(_Children, sizeof(*_Children));
	_Children = NULL;
	
	Permit();
	}
