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@gmail.com>
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 .\" Japanese Version Copyright (c) 2007 Akihiro MOTOKI
27 .\" all rights reserved.
28 .\" Translated 2007-02-04, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
30 .TH TEE 2 2009-09-15 "Linux" "Linux Programmer's Manual"
33 .\"O tee \- duplicating pipe content
38 .\"O .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
39 .BR "#define _GNU_SOURCE" " /* feature_test_macros(7) 参照 */"
42 .BI "ssize_t tee(int " fd_in ", int " fd_out ", size_t " len \
43 ", unsigned int " flags );
45 .\" Return type was long before glibc 2.7
48 .\" Example programs http://brick.kernel.dk/snaps
51 .\" add a "tee(in, out1, out2)" system call that duplicates the pages
52 .\" (again, incrementing their reference count, not copying the data) from
53 .\" one pipe to two other pipes.
57 .\"O bytes of data from the pipe referred to by the file descriptor
59 .\"O to the pipe referred to by the file descriptor
61 .\"O It does not consume the data that is duplicated from
63 .\"O therefore, that data can be copied by a subsequent
75 からは消費されない。したがって、これらのデータをこの後の
80 .\"O is a series of modifier flags, which share the name space with
83 .\"O .BR vmsplice (2):
92 .\"O Currently has no effect for
103 .\"O Do not block on I/O; see
105 .\"O for further details.
112 .\"O Currently has no effect for
114 .\"O but may be implemented in the future; see
118 では何の効果もないが、将来的には実装される可能性がある。
126 .\"O .BR vmsplice (2).
131 .\"O .SH RETURN VALUE
133 .\"O Upon successful completion,
135 .\"O returns the number of bytes that were duplicated between the input
137 .\"O A return value of 0 means that there was no data to transfer,
138 .\"O and it would not make sense to block, because there are no
139 .\"O writers connected to the write end of the pipe referred to by
144 返り値 0 はデータの転送が行われなかったことを示す。
145 この場合、処理を停止 (block) しても無意味である。
148 が参照するパイプの書き込み側に接続されている者がいないからである。
154 .\"O is set to indicate the error.
167 .\"O does not refer to a pipe; or
171 .\"O refer to the same pipe.
175 のどちらかがパイプを参照していない。もしくは
188 .\"O system call first appeared in Linux 2.6.17.
190 システムコールは Linux 2.6.17 で初めて登場した。
191 .\"O .SH "CONFORMING TO"
193 .\"O This system call is Linux-specific.
194 このシステムコールは Linux 固有である。
199 .\"O copies the data between the two pipes.
200 .\"O In reality no real data copying takes place though:
201 .\"O under the covers,
203 .\"O assigns data in the output by merely grabbing
204 .\"O a reference to the input.
208 しかし、実際には実データのコピーは行われない。
211 は入力側に対する参照だけを作成することで出力側にデータを
215 .\"O The following example implements a basic
217 .\"O program using the
237 main(int argc, char *argv[])
243 fprintf(stderr, "Usage: %s <file>\\n", argv[0]);
247 fd = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC, 0644);
255 * tee stdin to stdout.
257 len = tee(STDIN_FILENO, STDOUT_FILENO,
258 INT_MAX, SPLICE_F_NONBLOCK);
270 * Consume stdin by splicing it to a file.
273 slen = splice(STDIN_FILENO, NULL, fd, NULL,