简体   繁体   中英

What are the default stdin and stdout for a program started from desktop on Linux?

When I start a program from desktop (Ubuntu 16.04) instead of from shell so that the program is not associated with a terminal, what are the stdin and stdout for this program? Are STDIN_FILENO and STDOUT_FILENO valid file descriptors when the program starts? Where does printf write to in this case?

You can use the strace program to see all system calls a program is executing (like open, read, write, close). When you attatch it to the "Desktop program" (the one running your program; use pstree or proctree ), you can see what happens to file descriptors 0, 1 and 2.

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

Or google for "gnome run program stdout"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM