Possible Duplicate:
redirecting output to a file in C
I’m running a process as follows:
char* [NUM];
char[0] = processName;
char[1] = arg0;
...
char[NUM] = 0;
execv(args[0],args);
The question is how I can make it redirect its output to
/dev/null
I tried adding it to the args array but it sent it as arguments to the program…
Any idea anyone?
Thanks
First open the target you want, then close the
fdyou want toreassign, use
dup2to connect it there, and close the previous open: