Skip to content

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)

22 points10 comments
Open on Reddit
About this post
Posted
Archived
Score
22 · 100% up
Kind
Text
ID
3a4dca

Author

107
posts
276
comments
11
media
View profile

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.

11 points

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:

$journalctl -u session-cX.scope

(you get the session-cX.scope in the unit field of the first command)

17 points
  • OP is confusing TTY1 [...] and stdout

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?

2 points

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.

10 points

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.

2 points

You can also explictly see where do stdout and stderr go for a process. Just list the /proc/<pid>/fd/{0,1,2} links

$ ls -l /proc/729/fd/{0,1,2}
lr-x------ 1 damjan users 64 јун 16 20:06 /proc/729/fd/0 -> pipe:[17025]
l-wx------ 1 damjan users 64 јун 16 20:06 /proc/729/fd/1 -> /home/damjan/.xsession-errors
l-wx------ 1 damjan users 64 јун 16 20:06 /proc/729/fd/2 -> /home/damjan/.xsession-errors
1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.