/**********************************************************************
 
	Copyright (C) 2003 Hirohisa MORI <joshua@nichibun.ac.jp>
 
	This program is free software; you can redistribute it 
	and/or modify it under the terms of the GLOBALBASE 
	Library General Public License (G-LGPL) as published by 

	http://www.globalbase.org/
 
	This program is distributed in the hope that it will be 
	useful, but WITHOUT ANY WARRANTY; without even the 
	implied warranty of MERCHANTABILITY or FITNESS FOR A 
	PARTICULAR PURPOSE.

**********************************************************************/


#include	<stdlib.h>
#include	<limits.h>
#include	"memory_debug.h"
#include	"utils.h"
#include	"fcntl.h"

extern int max_fid;

void
launch_devnull(char * proc)
{
char * buf;
int id;
int i;
	buf = d_alloc(1000,144);
	id = fork();
	if ( id == 0 ) {
		id = open("/dev/null",O_WRONLY);
		for ( i = 1 ; i <= OPEN_MAX ; i ++  )
			close(i);
		dup(id);
		dup(id);
		close(id);
		sprintf(buf,"%s &",proc);
		system(buf);
		exit(0);
	}
	d_f_ree(buf);
}
