You're viewing a comment by Dave and its responses.

Dave Permalink
September 10, 2012, 18:15

You missed a couple:

Turn off input output (throw in to the background for fun too):
>&- <&- 2>&- &

Comment Responses

lava Permalink
September 11, 2012, 12:44

Warning: closing descriptors could cause some apps to fail, so be aware.
+-----------------------------------------------
|$ exec >&-
|-bash: echo: write error: Bad file descriptor
|-bash: echo: write error: Bad file descriptor
|$ ls
|ls: write error: Bad file descriptor
|-bash: echo: write error: Bad file descriptor
|$ echo $? >&2
|2
|-bash: echo: write error: Bad file descriptor
|-bash: echo: write error: Bad file descriptor
|

As you can see, not only error messages have been printed to the console, but ls also returned an error (2). This could be essential for scripts and I personally would recommend redirection to /dev/null.

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "coding_342": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.