If you want to redirect stdin, stdout, and stderr, the function you want is probably dup2(). e.g.
Code:
int fd;
fd = open("/dev/null", O_WRONLY);
if (fd < 0)
err(EXIT_FAILURE, "crap");
if (dup2(fd, fileno(stdout)) < 0)
err(EXIT_FAILURE, "dup2");
/* now stdout goes to /dev/null */