Where does output from programs go?
If I open a program from my terminal occasionally I'll get output from warnings and such. When I have LXDM start Openbox and then all my programs on top of Openbox, there is still TTY1 underneath all of that. Do programs I start from my application launcher write their output to TTY1 or /dev/null or somewhere else? If somewhere else, where? And how can I find it? I ask because when I tried FreeBSD a console window that was not a terminal would open when I logged in to X (more specifically when xdm started)
About this post
- Posted
- Archived
- Score
- 22 · 100% up
- Kind
- Text
- ID
- 3a4dca
10 comments
If the program is set to log, it'll write to logs (usually in /var/log, though I don't think programs are bound to respect that in any way and can use their own location). You may find warnings and so forth there - and probably more usable due to timestamps and the like. Beyond that, it seems that as graphical programs are children of the X process, their output generally gets written wherever X's output does - apparently
.Xsession-errors~/.xsession-errors.This stack exchange discussion might have more information of interest.
That's basically correct but a few points:
OP is confusing TTY1 (first virtual terminal) and stdout (FD 1 of the process) and stderr (FD 2 of the process). stdout/stderr is what the OP is looking for (VTs are what you switch between when using CTRL+ALT+FX).
This is not The X server output directlly.
Since this is arch, I'm assuming you are running systemd, your process are all in a session managed by systemd, that session is centralising the output and then putting it in .xsession-errors, you can have the same data with:
$ loginctl session-status
or for the full log:
(you get the session-cX.scope in the unit field of the first command)
Perhaps - I got a bit muddled and started thinking about an autologin to TTY and autostarting X from there, rather than the mentioned LXDM. Would that case put anything in TTY1?
Wow, thanks!
Wow. This is actually a really awesome question.
Sorry, I have nothing else to add. I've been using Linux for over a decade and I always thought the output was just lost.
In some cases, the output is discarded. In other cases, it is logged.
For example, if you put a
System.out.print("blah blah blah");call in a Java webapp that then runs on Tomcat, Tomcat will redirect it to the appropriate log file.It really depends on a program-by-program basis.
You can also explictly see where do stdout and stderr go for a process. Just list the /proc/<pid>/fd/{0,1,2} links
What does the pipe mean for fd/0?
it means its parent process set fd 0 as a pipe(2) possibly to monitor if it dies or for some communication.
http://www.manpages.info/linux/pipe.2.html