Skip to main content
added 373 characters in body
Source Link
Gilles 'SO- stop being evil'
  • 866.1k
  • 205
  • 1.8k
  • 2.3k

You were very close in showing the output of /proc/$pid/fd/1. As you saw, that will show you the output which is sent to stdout. But to see whenceforth standard output is being sent, you simply need to look at the target of that symbolic link:

$ sleep 20 & pid=$!
[1] 88972
$ readlink -f /proc/$pid/fd/1
/dev/pty0
$  sleep 20 > /dev/null & pid=$!
[1] 99996
readlink -f /proc/$pid/fd/1
/dev/null

If the target of the link is a pipe and you want to find what's at the other end, see Name of the process on the other end of a unix pipe?. If the target of the link is a socket and you want to find what's at the other end, see Who's got the other end of this unix socketpair?.

However, if you are seeing output other than what is being sent to your output.txt file, that seems to indicate that the output you're seeing is not in fact output (or more specifically is not standard output). It may be standard error, which is file descriptor 2.

You were very close in showing the output of /proc/$pid/fd/1. As you saw, that will show you the output which is sent to stdout. But to see whenceforth standard output is being sent, you simply need to look at the target of that symbolic link:

$ sleep 20 & pid=$!
[1] 88972
$ readlink -f /proc/$pid/fd/1
/dev/pty0
$  sleep 20 > /dev/null & pid=$!
[1] 99996
readlink -f /proc/$pid/fd/1
/dev/null

However, if you are seeing output other than what is being sent to your output.txt file, that seems to indicate that the output you're seeing is not in fact output (or more specifically is not standard output). It may be standard error, which is file descriptor 2.

You were very close in showing the output of /proc/$pid/fd/1. As you saw, that will show you the output which is sent to stdout. But to see whenceforth standard output is being sent, you simply need to look at the target of that symbolic link:

$ sleep 20 & pid=$!
[1] 88972
$ readlink -f /proc/$pid/fd/1
/dev/pty0
$  sleep 20 > /dev/null & pid=$!
[1] 99996
readlink -f /proc/$pid/fd/1
/dev/null

If the target of the link is a pipe and you want to find what's at the other end, see Name of the process on the other end of a unix pipe?. If the target of the link is a socket and you want to find what's at the other end, see Who's got the other end of this unix socketpair?.

However, if you are seeing output other than what is being sent to your output.txt file, that seems to indicate that the output you're seeing is not in fact output (or more specifically is not standard output). It may be standard error, which is file descriptor 2.

Source Link
DopeGhoti
  • 79.3k
  • 10
  • 107
  • 141

You were very close in showing the output of /proc/$pid/fd/1. As you saw, that will show you the output which is sent to stdout. But to see whenceforth standard output is being sent, you simply need to look at the target of that symbolic link:

$ sleep 20 & pid=$!
[1] 88972
$ readlink -f /proc/$pid/fd/1
/dev/pty0
$  sleep 20 > /dev/null & pid=$!
[1] 99996
readlink -f /proc/$pid/fd/1
/dev/null

However, if you are seeing output other than what is being sent to your output.txt file, that seems to indicate that the output you're seeing is not in fact output (or more specifically is not standard output). It may be standard error, which is file descriptor 2.