user716468
user716468

Reputation: 1623

I have redirected stdout and stderr, why do I still get some output?

I did something like the following in a bash terminal

( some_command ) >/dev/null 2>/dev/null

Yet I still got something printed. Here some_command runs a command-line program private to my organization. How did the sub-shell manage to print something to the console while I redirected both STDOUT and STDERR?

Upvotes: 3

Views: 426

Answers (1)

Eevee
Eevee

Reputation: 48536

One possibility is that the program is particularly rude and is printing to the controlling terminal directly, which would circumvent all redirecting.

For example:

$ ( echo "can't touch this" > /dev/tty ) >/dev/null 2>/dev/null
can't touch this

(/dev/tty refers to the current process's controlling terminal.)

Upvotes: 6

Related Questions