问题描述
if (out) {
out = 0;
int fd = open(output_file,O_WRONLY | O_CREAT,S_IRUSR | S_IWUSR);
if (fd == -1) perror("open for writing");
if (dup2(fd,STDOUT_FILENO) < 0) { perror("dup2"); abort();}
close(fd);
}
if (-1 == execvp(argv[0],argv)) {
perror("execvp");
printf(" (couldn't find command)\n");
}
exit(1);
在将输出重定向到一个单独的文件后,我试图将输出重定向回终端。此刻,当我打电话给我时,这种方法就起作用了:
$ ls > file.txt
但是,当我打电话
$ ls -l
此后,它将继续将其输出定向到file.txt,而不是终端。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)