Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Standard streams
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Standard error (stderr)==<!-- This section is linked from [[COMMAND.COM]] --> Standard error is another output stream typically used by programs to output [[error message]]s or diagnostics. It is a stream independent of standard output and can be redirected separately. This solves the [[semipredicate problem|semi-predicate problem]], allowing output and errors to be distinguished, and is analogous to a function returning a pair of values β see {{section link|Semipredicate problem|Multivalued return}}. The usual destination is the [[text terminal]] which started the program to provide the best chance of being seen even if ''standard output'' is redirected (so not readily observed). For example, output of a program in a [[pipeline (Unix)|pipeline]] is redirected to input of the next program or a text file, but errors from each program still go directly to the text terminal so they can be reviewed by the user in real time. It is acceptable and normal to direct ''standard output'' and ''standard error'' to the same destination, such as the text terminal. Messages appear in the same order as the program writes them, unless [[Data buffer|buffering]] is involved. For example, in common situations the standard error stream is unbuffered but the standard output stream is line-buffered; in this case, text written to standard error later may appear on the terminal earlier, if the standard output stream buffer is not yet full. The [[file descriptor]] for standard error is defined by [[POSIX]] as 2 (two); the ''<unistd.h>'' header file provides the symbol <code>STDERR_FILENO</code>;<ref>{{cite web |url=http://pubs.opengroup.org/onlinepubs/009695399/basedefs/unistd.h.html |work=The Open Group Base Specifications Issue 6—IEEE Std 1003.1, 2004 Edition |title=<unistd.h> |publisher=The Open Group |year=2004 }}</ref> the corresponding C <code><stdio.h></code> variable is <code>FILE* stderr</code>. The C++ <code><iostream></code> standard header provides two variables associated with this stream: <code>std::cerr</code> and <code>std::clog</code>, the former being unbuffered and the latter using the same buffering mechanism as all other C++ streams. [[Bourne shell|Bourne]]-style shells allow ''standard error'' to be redirected to the same destination that standard output is directed to using 2>&1 [[C shell|csh]]-style shells allow ''standard error'' to be redirected to the same destination that standard output is directed to using >& Standard error was added to Unix in the 1970s after several wasted phototypesetting runs ended with error messages being typeset instead of displayed on the user's terminal.<ref>{{cite mailing list |url=https://minnie.tuhs.org/pipermail/tuhs/2013-December/006113.html |title=[TUHS] Graphic Systems C/A/T phototypesetter |work=The Unix Heritage Society |date=2013-12-11 |first=Steve |last=Johnson |author-link=Stephen C. Johnson |access-date=2020-11-07 |url-status=live |archive-url=https://web.archive.org/web/20200925010614/https://minnie.tuhs.org/pipermail/tuhs/2013-December/006113.html |archive-date=2020-09-25}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)