小编Yi *_*Liu的帖子

如何恢复被dup2覆盖的stdin?

我试图用另一个管道替换stdin,然后将原始stdin放回到fd#0.

例如

dup2(p, 0); // p is a pre-existing fd of a pipe
exec(/* some commands */);

//what will be here in order to have the original stdin back?

scanf(...) //continue processing with original stdin.
Run Code Online (Sandbox Code Playgroud)

c unix file-descriptor dup2

4
推荐指数
1
解决办法
176
查看次数

标签 统计

c ×1

dup2 ×1

file-descriptor ×1

unix ×1