#include <arpbase.h>
#include <arp_proto.h>
#include "Launch.h"
#include "LaunchPriv.h"

/*
 *	NAME
 *		KillProcesses -- try to kill all child via a signal.
 *
 *	SYNOPSIS
 *		KillProcesses ()
 *
 *		void KillProcesses (void);
 *
 *	DESCRIPTION
 *		Send a KILL_PROCESS_FLAG signal to all child process of this
 *		process.
 *
 *	INPUT
 *		None.
 *
 *	OUTPUT
 *		None.
 *
 *	NOTE
 *		This only tries to kill your OWN child processes, not children
 *		of your children.
 *
 *		This function does not wait to see if the processes really die,
 *		you MUST call WaitProcesses() before quitting !!!
 *
 *	HISTORY
 *		1992/09/06	Pierre Baillargeon		Creation
 *
 *	SEE ALSO
 *		StartProcess(), WaitProcesses(), WaitProcess()
 */

void KillProcesses (void)
{
	struct Process *Proc;
	struct ProcPair *pp;

	Forbid ();
	if (ProcPairList)
	{
		Proc = (struct Process *)FindTask (NULL);

		for (pp = (struct ProcPair *)ProcPairList->lh_Head; pp->pp_Node.ln_Succ; pp = (struct ProcPair *)pp->pp_Node.ln_Succ)
		{
			if (Proc == pp->pp_Parent)
			{
				Signal (pp->pp_Child, KILL_PROCESS_FLAG);
			}
		}
	}
	Permit ();
}
