在Linux上从桌面启动的程序的默认stdin和stdout是什么?

时间:2016-10-30 07:38:40

标签: c linux stdout stdin desktop

当我从桌面(Ubuntu 16.04)而不是shell启动程序时,程序与终端没有关联,这个程序的stdin和stdout是什么?程序启动时是STDIN_FILENOSTDOUT_FILENO有效的文件描述符吗?在这种情况下printf写在哪里?

1 个答案:

答案 0 :(得分:0)

您可以使用strace程序查看程序正在执行的所有系统调用(如打开,读取,写入,关闭)。当你将它附加到"桌面程序" (运行程序的那个;使用pstreeproctree),你可以看到文件描述符0,1和2会发生什么。

请参阅https://superuser.com/questions/606985/any-way-to-view-stdout-of-a-program-after-it-has-been-started-in-gnome-shell

或google for" gnome run program stdout"