Skip to content
Search

Standard streams

lastmod 2024-07-09created 2015-08-295 edits

Standard streams are preconnected input and output channels between a computer program and its environment (typically a terminal) in Unix and Unix-like operating systems (and, to some extent, Windows), as well as in certain programming language interfaces. There are three I/O connections: standard input (stdin), standard output (stdout), and standard error (stderr).

DEFINE

They are defined as stdin, stdout, and stderr in the stdio.h header of the standard C runtime library, and are also represented as file descriptors 0, 1, and 2 by unistd.h.

In Linux, which was strongly influenced by Unix, the file descriptors of the standard streams are also reserved.

Standard I/O Pipe speed test

Use the dd command.

dd if=/dev/zero bs=24M count=1024 | dd of=/dev/null
  • if=/dev/zero - Reads zero-filled data. (Input File)
  • bs=1M - Reads data in 1MB blocks.
  • count=1024 - Reads 1024 blocks (i.e., reads 1GB of data).
  • of=/dev/null - Discards the data. (Output File)

You can see a log like the following.

1024+0 records in
1024+0 records out
25769803776 bytes (26 GB, 24 GiB) copied, 36.7413 s, 701 MB/s
50331648+0 records in
50331648+0 records out
25769803776 bytes (26 GB, 24 GiB) copied, 36.7413 s, 701 MB/s

See also

Favorite site

author Zer0 sitemap