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"
32 tee \- ¥Ñ¥¤¥×¤ÎÃæ¿È¤òÊ£À½¤¹¤ë
35 .BR "#define _GNU_SOURCE" " /* feature_test_macros(7) »²¾È */"
38 .BI "ssize_t tee(int " fd_in ", int " fd_out ", size_t " len \
39 ", unsigned int " flags );
41 .\" Return type was long before glibc 2.7
43 .\" Example programs http://brick.kernel.dk/snaps
46 .\" add a "tee(in, out1, out2)" system call that duplicates the pages
47 .\" (again, incrementing their reference count, not copying the data) from
48 .\" one pipe to two other pipes.
50 ¤Ï¡¢¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿
52 ¤¬»²¾È¤¹¤ë¥Ñ¥¤¥×¤«¤é¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿
54 ¤¬»²¾È¤¹¤ë¥Ñ¥¤¥×¤ØºÇÂç
56 ¥Ð¥¤¥È¤Î¥Ç¡¼¥¿¤òÊ£À½¤¹¤ë¡£
57 ¤³¤ÎÁàºî¤Ç¤Ï¡¢Ê£À½¤µ¤ì¤ë¥Ç¡¼¥¿¤Ï
59 ¤«¤é¤Ï¾ÃÈñ¤µ¤ì¤Ê¤¤¡£¤·¤¿¤¬¤Ã¤Æ¡¢¤³¤ì¤é¤Î¥Ç¡¼¥¿¤ò¤³¤Î¸å¤Î
61 ¤Ç¥³¥Ô¡¼¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¡£
64 ¤Ï°ìÏ¢¤Î½¤¾þ¥Õ¥é¥°¤Ç¤¢¤ê¡¢
78 Æþ½ÐÎÏ»þ¤ËÄä»ß (block) ¤·¤Ê¤¤¡£
86 ¤Ç¤Ï²¿¤Î¸ú²Ì¤â¤Ê¤¤¤¬¡¢¾ÍèŪ¤Ë¤Ï¼ÂÁõ¤µ¤ì¤ë²ÄǽÀ¤¬¤¢¤ë¡£
98 ¤ÏÆþ½ÐÎÏ´Ö¤ÇÊ£À½¤µ¤ì¤¿¥Ð¥¤¥È¿ô¤òÊÖ¤¹¡£
99 ÊÖ¤êÃÍ 0 ¤Ï¥Ç¡¼¥¿¤ÎžÁ÷¤¬¹Ô¤ï¤ì¤Ê¤«¤Ã¤¿¤³¤È¤ò¼¨¤¹¡£
100 ¤³¤Î¾ì¹ç¡¢½èÍý¤òÄä»ß (block) ¤·¤Æ¤â̵°ÕÌ£¤Ç¤¢¤ë¡£
103 ¤¬»²¾È¤¹¤ë¥Ñ¥¤¥×¤Î½ñ¤¹þ¤ß¦¤ËÀܳ¤µ¤ì¤Æ¤¤¤ë¼Ô¤¬¤¤¤Ê¤¤¤«¤é¤Ç¤¢¤ë¡£
109 ¤Ë¥¨¥é¡¼¤ò¼¨¤¹ÃͤòÀßÄꤹ¤ë¡£
116 ¤Î¤É¤Á¤é¤«¤¬¥Ñ¥¤¥×¤ò»²¾È¤·¤Æ¤¤¤Ê¤¤¡£¤â¤·¤¯¤Ï
120 ¤¬Æ±¤¸¥Ñ¥¤¥×¤ò»²¾È¤·¤Æ¤¤¤ë¡£
126 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï Linux 2.6.17 ¤Ç½é¤á¤ÆÅо줷¤¿¡£
128 ¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï Linux ¸ÇͤǤ¢¤ë¡£
132 ¤ÏÆó¤Ä¤Î¥Ñ¥¤¥×´Ö¤Ç¥Ç¡¼¥¿¤Î¥³¥Ô¡¼¤ò¹Ô¤¦¡£
133 ¤·¤«¤·¡¢¼ÂºÝ¤Ë¤Ï¼Â¥Ç¡¼¥¿¤Î¥³¥Ô¡¼¤Ï¹Ô¤ï¤ì¤Ê¤¤¡£
136 ¤ÏÆþÎϦ¤ËÂФ¹¤ë»²¾È¤À¤±¤òºîÀ®¤¹¤ë¤³¤È¤Ç½ÐÎϦ¤Ë¥Ç¡¼¥¿¤ò
141 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤ò»È¤Ã¤Æ¡¢
144 ¥×¥í¥°¥é¥à¤ò¼ÂÁõ¤·¤¿¤â¤Î¤Ç¤¢¤ë¡£
156 main(int argc, char *argv[])
162 fprintf(stderr, "Usage: %s <file>\\n", argv[0]);
166 fd = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC, 0644);
174 * tee stdin to stdout.
176 len = tee(STDIN_FILENO, STDOUT_FILENO,
177 INT_MAX, SPLICE_F_NONBLOCK);
189 * Consume stdin by splicing it to a file.
192 slen = splice(STDIN_FILENO, NULL, fd, NULL,