Jump to content

Talk:Standard streams

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Stdin to display status?

[edit]

The GUIs section states that the dwm tiling window manager "uses its stdin to display status information". Is this correct? Surely stdout or stderr is intended. Nate (talk) 16:10, 20 March 2008 (UTC)[reply]

stdpasswd

[edit]

Has anybody heard of stdpasswd used as a standardized stream anywhere? kostmo (talk) 04:21, 28 December 2008 (UTC)[reply]

C# Example

[edit]

Monkeycoders on teh my wikipedia. Fixed for great coding style —Preceding unsigned comment added by 93.92.205.25 (talk) 08:06, 10 April 2009 (UTC)[reply]

FILENO

[edit]

What does FILENO stand for? Thanks, --Abdull (talk) 11:22, 25 May 2010 (UTC)[reply]

I'm pretty sure it means file number. It's a very short name because of the limitations of 1970s era C compilers which typically ignored anything passed about 7 or 8 characters in an identifier. —EncMstr (talk) 17:11, 25 May 2010 (UTC)[reply]

Affected by proposed renaming

[edit]

Presently standard error (presently disambiguation) and standard error stream are pointed to or redirect to this article. There is a formal proposed renaming/move at Talk:Standard error (statistics)#Requested move that would affect these routes to this article. Unfortunately, this discussion is only open for 7 days, so be quick if you want your opinion to count. Melcombe (talk) 19:30, 15 February 2012 (UTC)[reply]

Encoding inconsistency

[edit]

I read Popular Windows programs that open a separate console window in addition to their GUI windows are the emulators pSX and DOSBox.

Nonethess, from my undesrstanding, Windows application run with text encoded in UTF-16, UTF-8, or windows-1252; when DOS box is configured for CP850. This mean that they cannot display the same set of character, and so their interoperability is limited, and cannot be used neither easily, nor by default which is opposite to the unix philosophy described in background section. — Preceding unsigned comment added by 86.75.160.141 (talk) 12:18, 11 November 2012 (UTC)[reply]

PHP

[edit]

idk if it should go in the article, but in PHP, its php://stdin , php://stdout , php://stderr [1] since 2002 / PHP 4.3.0 [2][3] Divinity76 (talk) 15:41, 7 September 2013 (UTC)[reply]

Origin of stderr

[edit]

While a bit unusual, I don't see why the material about the origin of stderr was removed. Yes, it's a self-published primary source, but the author can certainly be considered an expert, and I don't see anything in WP:V that prohibits this unless you think it's somehow controversial, which it's not as far as I know. Your comment about v6 makes no sense to me; Johnson doesn't say, but this would have been about 1973, and v6 wasn't released until 1975. Do you doubt this actually happened, or are you just unhappy with the source? Kendall-K1 (talk) 22:14, 19 December 2013 (UTC)[reply]

I am unhappy about several aspects:
  1. the source: I am not familiar with sjc @ yaccman. Is that a reliable source? Certainly the newsgroup is not fact checked.
  2. the assertion: While the story seems like it could be plausible, it doesn't need to be. Unix borrowed much from Multics which had stderr. Why would they not have added that with stdout?
  3. the lack of dates: If the event occurred in 1973, then that could fit. But nothing here gives dates.
While I would like to see any tidbit on the origin of these, the prime policy of verifiability being observed would help this lore be defended and greatly improve the article. —EncMstr (talk) 04:42, 20 December 2013 (UTC)[reply]
Bell Labs installed their CAT in 1973, and this would have been soon after that. S. C. Johnson worked there at the time. He was co-author with Kernighan of "THE PROGRAMMING LANGUAGE B" and several other CSTRs [1]. Unix did borrow a lot from Multics, but what really distinguished Unix was the vast amount of Multics stuff they deliberately left out. While the mailing list (not newsgroup) is not fact checked, I have no doubt this was actually written by scj. You could argue that his memory could be faulty. But this entire article is almost completely unsourced, so picking on one tidbit that actually is sourced seems odd to me. Kendall-K1 (talk) 11:48, 20 December 2013 (UTC)[reply]
Looking more deeply, seems like a valid cite to material of The Unix Heritage Society to me. If I could get a provenance like that - a written conversation between Douglas McIlroy and Larry McVoy and other prime movers - on other stories of computer history, I'd be grateful. Added back with clearer citation. ★NealMcB★ (talk) 20:03, 2 July 2015 (UTC)[reply]

Inconsistency

[edit]

"stdin", "stdout" and "stderr" are "channels", "file handles" or "ports". They are not "streams". Calling them "streams" is inconsistent with the definition of Stream (computing): "a sequence of data elements made available over time"

When you "write data to stdout", the "stream" is *your data*, not "stdout". Std-out is just a standardized file handle number. The best analogy is a "channel". "stdout" is *where* you write the *stream* (your data).

Also here Redirection (computing) it reads: *"Redirecting to and from the standard file handles"*. What is "standard" in std-in and std-out is that input stream is read from file handle 0 and output stream is sent to file handle 1. "stdin" is a file handle, and the "input stream" is the data you receive by reading from stdin.

"stream" is data, while a "channel" is a medium. "stdin" and "stdout", from a programming point of view, are channels, mediums.

In the sentence "write data to stdout". *data* is the *stream* and "stdout" is the *channel*.

You cannot "write data to a stream", the data *is* the stream.

I believe this article should be called "Standard channels" or "Standard file handles", and also the text should be revised to avoid conflating "stream" with "channel".

Moreover, this article starts:

> "In computer programming, standard streams are preconnected input and output streams (communication channels)"

implying that a "stream" is a "communication channel" -which is not- by definition from this same encyclopedia: Stream (computing)

By replacing "stream" with "channel" in the text of the article, the inconsistencies are resolved.e.g.:

> "In computer programming, standard channels are preconnected input and output channels" — Preceding unsigned comment added by Luciotato (talk) 19:09, 23 January 2015 (UTC)[reply]

I suspect you are confused by C++ conventions which has a stream object type—which contains sequenced data—since the late 1980s; C++ streams are based on i/o streams from the 1970s which truly are a raw i/o mechanism and might contain any kind of data—keyboard input, line printer control instructions, or even C++ data object representations.
However, your interpretation is likely to be widespread among recent computer science students so some sort of clarification is justified. —EncMstr (talk) 19:31, 23 January 2015 (UTC)[reply]
I'm pointing out inconsistencies in the definition of terms. If the article title is "Standard streams" then why the first statement says "This article is about standard I/O file descriptors"?. Is a "stream" a "file descriptor"? or a stream is a "sequence of data"?
also from the article:
> ...are preconnected input and output streams (communication channels)
it is implying that a "Stream" is a "communication channel"?
Given the definition of Streams this article is misusing the term. Without considering any programming language, the usage of the word "stream" in this article is inconsistent with the definition of stream. It is a problem of internal consistency of the encyclopedia. Luciotato (talk) 19:59, 23 January 2015 (UTC)[reply]

There has always been this inconsistently with stream I/O. It is common to refer to stdin, stdout, and stderr as stream input and output channels. as the stdin input stream terminology I beleave predates the current stream I/O defination.

UNIX bullshit

[edit]

Mainframe operating systems like RCA's TSOS had the abstracted devices the article claims for UNIX quite some time before UNIX! STDIN was read via RDATA macro/SVC, writing to STDOUT was done via WROUT macro/SVC. Assignment of the streams to file was done via the /SYSFILE JCL command. — Preceding unsigned comment added by 84.153.132.112 (talk) 19:32, 25 December 2017 (UTC)[reply]

FORTRAN77 example

[edit]

Hi,
while the numbers in the FORTRAN77 example are indeed those often used for the standard streams (at least stdin and stdout, not sure about stderr), the FORTRAN77 language as standardised does only distinguish between standard input and standard output. Also it defines a portable way to excess those. The portable, standard-conforming variant of the example reads:

C     FORTRAN 77 example
      PROGRAM MAIN
        INTEGER NUMBER
        READ(*,*) NUMBER
        WRITE(*,'(A,I3)') ' NUMBER IS: ',NUMBER
      END

More concisely one could code the example as

C     FORTRAN 77 example
      PROGRAM MAIN
        INTEGER NUMBER
        READ *, NUMBER
        PRINT '(A,I3)', ' NUMBER IS: ',NUMBER
      END

The "!" as comment character was only introduced in Fortran90, btw.
Cheers
InfoBroker2020 (talk) 12:25, 14 May 2018 (UTC)[reply]

language’s English (en)
Username’s:
@KuGau0xxx 2603:8000:6202:D0C3:642D:2DD6:97E1:6E60 (talk) 05:13, 30 January 2024 (UTC)[reply]

A confused and misleading article

[edit]

This article is riddled with errors, inaccuracies, and irrelevancies. Here are some:

- "Originally I/O happened via a physically connected system console (input via keyboard, output via monitor)" It's hard to guess what "originally" means here, but the earliest electronic computers, such as the ENIAC, used card readers and punches for I/O. [ENIAC] Later, the first Fortran manual discussed I/O to a card reader, a card punch, a line printer, one of various tape units, or drum (i.e., no console or terminal). [Fortran.56]

- "The data [transmitted to or received from a standard stream] may be text... or binary data." This is true in a POSIX environment, but is not required to hold everywhere. For example ISO C specifies that standard input, standard output, and standard error are to be "text streams", that is, configured to support textual I/O, not necessarily binary I/O. [ISOC]

- "When a program is run as a daemon, the standard error stream is redirected to a log file." Some daemons may work this way, but it's not universal. Some daemons use syslog, whose C-level API doesn't involve any explicit stream. Further, the daemon(3) libc routine (not standardized, but available on many Unix-like systems) has a built-in capability for associating all 3 of stdin, stdio, and stderr with /dev/null; so at least some developers have considered a "daemon" to be a program that doesn't use the standard streams. [daemon.3]

- "Streams may be used to chain applications..." This whole paragraph discusses a feature, pipes, that is orthogonal to the abstract idea of "preconnected" streams in general, and to the particular complement of preconnected streams Unix popularized. Multics had the notion of a predefined a number of streams for each process before Unix came along, but seems to have omitted pipes till about 1987. [Multics.streams], [Multics.pipes].

- "In most operating systems predating Unix, programs had to explicitly connect to the appropriate input and output devices." It's unclear what to make of the word, "most", but this is historically inaccurate among timesharing operating systems that predated Unix. Programs on MIT's CTSS did not take special action to connect to a user's terminal: the login service connected the user's process to the terminal, and subsequent programs had handles for the terminal thereafter. [CTSS] The Berkeley Time Sharing System, Dartmouth Time Sharing System, and Multics (all predating Unix) did likewise. [SDS940], [DTSS], [MTB-010] (I'll note that these timesharing systems had academic research origins, and probably had fewer total users than any commercial products of the time. It might be true that most computer users in the 1960s would have been working with commercial, batch-oriented systems; if this was the case, the paragraph might accurately characterize the lived experience of the median practitioner, but not the state of the art, prior to the popularization of Unix and other timesharing systems in the '70s.)

- "One of Unix's several groundbreaking advances was abstract devices, which removed the need for a program to know or care what kind of devices it was communicating with." One core design goal of Multics was device-independent I/O. Unix didn't invent it. [Corbato]

- "Older operating systems forced upon the programmer a record structure and frequently non-orthogonal data semantics and device control..." [through the end of the paragraph] Low-level I/O in CTSS was effectively stream oriented, and Multics had stream-oriented I/O from the start. (See previous citations for CTSS and Multics.) So Unix didn't invent stream I/O. Moreover, this is irrelevant to the subject of standard streams per se. Consider, for example, that although IBM mainframe systems such as MVS "natively" offer record-oriented I/O, a C program running on such a system has the three streams customary to the C language. [MVS] In other words, an operating system's customary I/O models and interfaces have no bearing on whether programs have access to a complement of preconnected I/O streams.

- "Another Unix breakthrough was to automatically associate input and output to terminal keyboard and terminal display, respectively, by default" [through end of the paragraph] As discussed above, this is a common trait among several timesharing operating systems that predated Unix. Further, the terms "associate" and "by default" are doing a lot of dubious work in that sentence. It's not entirely accurate to say that a Unix process is associated with a terminal: on the system where I'm typing, the overwhelming majority of processes are system daemons that have no controlling tty; and at a mechanical level, file descriptor connections and any other process-to-device associations are inherited from the parent process. So I guess we're supposed to interpret the qualifer "by default" as referring neither the distribution of observable processes on systems nor to the actual behavior a Unix system implements, but instead to a particular idealized "mode" of execution (i.e., a process invoked from an interactive shell session without any redirections in effect). That's fine! But even under that interpretation, there remains a lurking ambiguity: on most Unixes (excepting Research Unix 8th Edition and perhaps its successors), in order for a process to do I/O on the controlling terminal, e.g., to prompt the user for a password, the process must open /dev/tty explicitly. So I think one can reasonably characterize the relationship between a process and its controlling terminal as an "association" that's orthogonal to the set of I/O channels a process has open at some moment. This distinction further undermines whatever the point this imprecise and inaccurate sentence was supposed to have.

- "On POSIX systems, the file descriptor for standard input is 0 (zero); the corresponding C abstraction ... is provided by ... stdin... Similar abstractions exist in the standard I/O libraries of practically every programming language." The is how the functionality gets layered on Unix systems, where the I/O primitives take file descriptors; but that layering is an implementation detail as far as POSIX is concerned. POSIX requires interfaces for getting a file descriptor from a stream and making a stream from a file descriptor, but the stream could be the primitive and the file descriptor the abstraction.

- "Messages appear in the same order as the program writes them, unless buffering is involved." This is a property of C's stdio implementation tradition, not an intrinsic property of buffered I/O per se. For example, the sfio library, which extends stdio's interface, provides a mechanism to "pool" streams in order to ensure faithful ordering of buffered output among streams. [sfio] Anyhow, this trivia is largely orthogonal to the notion of preconnected I/O channels.

- "Fortran has the equivalent of Unix file descriptors" This is misleading: any system that uses first-class values for I/O handles needs to pick some data type as the representation. Both Fortran and Unix use integers, but that's happenstance.

- "By convention, many Fortran implementations use unit numbers UNIT=5 for stdin, UNIT=6 for stdout and UNIT=0 for stderr." I've no idea if this is true today, but even if so it's a modern convention (and slightly misleading juxtaposed beside the proposition that Fortran's unit numbers are equivalent to file descriptors): the roles of Fortran's unit 5 and 6 were implementation-dependent conventional assignments to a card reader and line printer respectively, unrelated to an interactive terminal. [Fortran.units]

- "[Algol 68's] model included three standard channels: stand in, stand out, and stand back." This presentation is subtly misleading at best. Algol 68's stand in and stand out are roughly analogous to stdin and stdout, but according to Tanenbaum, stand back is a random-access "binary scratch file", that is, a handle to storage used for augmenting the working set. [Tanenbaum] Because the rest of this article is about channels used only for unidirectional I/O, it's debatable whether stand back, a bidirectional handle, ought to be compared to the article's "standard streams".

- "In the C programming language, the standard input, output, and error streams are attached to the existing Unix file descriptors 0, 1 and 2 respectively." This is false about the C programming language in general. ISO C has streams; the POSIX extension to ISO C adds the concept of file descriptors and a correspondence between standard streams and file descriptors 0, 1 and 2. File descriptors need not exist on non-POSIX C implementations.

- "Diagnostics were part of standard output through Version 6, after which Dennis M. Ritchie created the concept of standard error." Although Ritchie implemented standard error on Unix, he wasn't the first to invent the concept of a distinguished stream for errors and diagnostics. Multics documented a standardized error_output stream in October 1973, around the release date of Unix version 4, fully two years before Unix version 6. I've no idea how much, if any, cross-fertilization happened between Multics and Unix after Bell Labs left the project in 1969, though it seems plausible. At best, Unix's standard error may have been an independent reinvention. [MTB-010] [Unix.dates]

IOW, this article variously misinforms and misleads anybody who looks at it for historical or comparative background, both on the specific topic of the complement of preconnected I/O handles popularized by Unix, and on the general idea that many operating systems and many programming languages have furnished programs with complements of preconnected I/O handles, albeit quite differently among systems and languages when you look carefully. (The general topic may not be appropriate for a Wikipedia article, though, since "preconnected I/O handle" is at best an ad hoc generalization contrived to establish an equivalence across unrelated and subtly different ways of addressing myriad issues in the relationships among programs and their execution environments. OTOH, I landed upon this article while researching how different systems and languages addressed some of these issues, so I, at least, wanted a treatment of the general topic once.)

References and further reading:

[CTSS] https://people.csail.mit.edu/saltzer/CTSS/CTSS-Documents/CTSS_ProgrammersGuide_1963.pdf

[Corbato] https://www.multicians.org/fjcc1.html See in particular "Design Considerations In The Communication And Input/Output Equipment"

[daemon.3] https://www.man7.org/linux/man-pages/man3/daemon.3.html

[DTSS] https://bitsavers.org/pdf/dartmouth/BASIC_Oct64.pdf pp 14 (PDF page 20) and following. (Note: this is the manual for BASIC on DTSS; BASIC appears to have been the most important "system" on DTSS at the time. Other contemporanous DTSS documentation exists, but none describes systems other than BASIC in much detail.)

[ENIAC] https://www.seas.upenn.edu/about/history-heritage/eniac/

[Fortran.56] http://archive.computerhistory.org/resources/text/Fortran/102649787.05.01.acc.pdf See pages 24 and following.

[Fortran.units] https://web.archive.org/web/20230417134120/https://www.star.le.ac.uk/~cgp/prof77.html

[ISOC] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf See section 7.21.3, point 7 and then 7.21.2 points 2 and 3.

[MTB-010] https://multicians.org/mtbs/MTB-010.pdf

[Multics.streams] https://multicians.org/mspm/bb-5-07.661101.reserved-stream-names.pdf

[Multics.pipes] https://multicians.org/mtbs/mtb763.html

[MVS] I'm not terribly familiar with IBM documentation, but this video eventually shows examples of running C programs on the platform: https://www.youtube.com/watch?v=Wl8qG9KilJg

[SDS940] http://bitsavers.org/pdf/sds/9xx/940/901116A_940_TimesharingTechMan_Nov67.pdf See pages 12 and following.

[sfio] https://archive.org/details/1991-proceedings-tech-conference-nashville/page/234/mode/2up?view=theater

[Unix.dates] https://en.wikipedia.org/wiki/Research_Unix

[Tanenbaum] Tanenbaum, A.S., "A Tutorial on Algol 68" (1973) https://dl.acm.org/doi/10.1145/356669.356671. See PDF page 30. 162.84.130.2 (talk) 18:05, 27 October 2024 (UTC)[reply]