1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" This manpage is Copyright (C) 2006 Jens Axboe
4 .\" and Copyright (C) 2006 Michael Kerrisk <mtk-manpages@gmx.net>
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date. The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein. The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
26 .TH tee 2 2006-04-28 "Linux 2.6.17" "Linux Programmer's Manual"
28 tee \- duplicating pipe content
31 .B #define _GNU_SOURCE
34 .BI "long tee(int " fd_in ", int " fd_out ", size_t " len \
35 ", unsigned int " flags );
38 .\" Example programs http://brick.kernel.dk/snaps
41 .\" add a "tee(in, out1, out2)" system call that duplicates the pages
42 .\" (again, incrementing their reference count, not copying the data) from
43 .\" one pipe to two other pipes.
47 bytes of data from the pipe referred to by the file descriptor
49 to the pipe referred to by the file descriptor
51 It does not consume the data that is duplicated from
53 therefore, that data can be copied by a subsequent
57 is a series of modifier flags, which share the name space with
63 Currently has no effect for
69 Do not block on I/O; see
74 Currently has no effect for
76 but may be implemented in the future; see
85 Upon successful completion,
87 returns the number of bytes that were duplicated between the input
89 A return value of 0 means that there was no data to transfer,
90 and it would not make sense to block, because there are no
91 writers connected to the write end of the pipe referred to by
98 is set to indicate the error.
105 does not refer to a pipe; or
109 refer to the same pipe.
116 copies the data between the two pipes.
117 In reality no real data copying takes place though:
120 assigns data in the output by merely grabbing
121 a reference to the input.
123 The following example implements a basic
140 main(int argc, char *argv[])
147 fd = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC, 0644);
155 * tee stdin to stdout.
157 len = tee(STDIN_FILENO, STDOUT_FILENO,
158 INT_MAX, SPLICE_F_NONBLOCK);
170 * Consume stdin by splicing it to a file.
173 slen = splice(STDIN_FILENO, NULL, fd, NULL,
190 system call first appeared in Linux-2.6.17.
192 This system call is Linux specific.