#include <u.h>
#include <libc.h>
#define NODEFINE
#include <9pm/u.h>
#include <9pm/libc.h>
#include <9pm/ns.h>

/*
 * System-specific additions to the pm_rfork implementation.
 * Pm_rfork has already done a good job, we just help out where we can.
 * 
 * Handled is only for flags we completely handle.
 */
int
pm_sysrfork(int flag)
{
	int handled = 0;

	/*
	 * if(flag&PM_RFFDG),
	 * it's not clear how much we should help.  in order to
	 * get it right, we'd have to walk the entire Fgrp, making
	 * new Chan structures for each Chan that had a sysfd.
	 * then we could reasonably rfork(RFFDG).  this might be
	 * worthwhile eventually, but for now let's hold off.
	 */

	if(flag&PM_RFCFDG)
		rfork(RFCFDG);

	if(flag&PM_RFNOTEG){
		rfork(RFNOTEG);
		handled |= PM_RFNOTEG;
	}
	return handled;
}
