我写了这个简单的程序。我希望将它的输出记录到下面打开的 test.log 中。我可以这样做吗?
int main(int argc, char **argv)
{
int fd = open("test.log", O_CREAT|O_WRONLY);
char *path[2];
path[0] = "/bin/ls";
path[1] = NULL;
execve((char *)&path[0], &path, NULL);
close(fd);
return 0;
}