X-Git-Url: http://git.osdn.net/view?p=linuxjm%2FLDP_man-pages.git;a=blobdiff_plain;f=draft%2Fman2%2Ftee.2;fp=draft%2Fman2%2Ftee.2;h=0000000000000000000000000000000000000000;hp=29587635544b10606fc449d567bcc655176ce61c;hb=2460a0b8024ceb8570acdbc9208713d79458efcb;hpb=83f9e5d087c3464d5131604d3c9893479e6228eb diff --git a/draft/man2/tee.2 b/draft/man2/tee.2 deleted file mode 100644 index 29587635..00000000 --- a/draft/man2/tee.2 +++ /dev/null @@ -1,174 +0,0 @@ -.\" This manpage is Copyright (C) 2006 Jens Axboe -.\" and Copyright (C) 2006 Michael Kerrisk -.\" -.\" %%%LICENSE_START(VERBATIM) -.\" Permission is granted to make and distribute verbatim copies of this -.\" manual provided the copyright notice and this permission notice are -.\" preserved on all copies. -.\" -.\" Permission is granted to copy and distribute modified versions of this -.\" manual under the conditions for verbatim copying, provided that the -.\" entire resulting derived work is distributed under the terms of a -.\" permission notice identical to this one. -.\" -.\" Since the Linux kernel and libraries are constantly changing, this -.\" manual page may be incorrect or out-of-date. The author(s) assume no -.\" responsibility for errors or omissions, or for damages resulting from -.\" the use of the information contained herein. The author(s) may not -.\" have taken the same level of care in the production of this manual, -.\" which is licensed free of charge, as they might when working -.\" professionally. -.\" -.\" Formatted or processed versions of this manual, if unaccompanied by -.\" the source, must acknowledge the copyright and authors of this work. -.\" %%%LICENSE_END -.\" -.\"******************************************************************* -.\" -.\" This file was generated with po4a. Translate the source file. -.\" -.\"******************************************************************* -.\" -.\" Japanese Version Copyright (c) 2007 Akihiro MOTOKI -.\" all rights reserved. -.\" Translated 2007-02-04, Akihiro MOTOKI -.\" -.TH TEE 2 2014\-12\-31 Linux "Linux Programmer's Manual" -.SH 名前 -tee \- パイプの中身を複製する -.SH 書式 -.nf -\fB#define _GNU_SOURCE\fP /* feature_test_macros(7) 参照 */ -\fB#include \fP - -\fBssize_t tee(int \fP\fIfd_in\fP\fB, int \fP\fIfd_out\fP\fB, size_t \fP\fIlen\fP\fB, unsigned int \fP\fIflags\fP\fB);\fP -.fi -.\" Return type was long before glibc 2.7 -.SH 説明 -.\" Example programs http://brick.kernel.dk/snaps -.\" -.\" -.\" add a "tee(in, out1, out2)" system call that duplicates the pages -.\" (again, incrementing their reference count, not copying the data) from -.\" one pipe to two other pipes. -\fBtee\fP() は、ファイルディスクリプター \fIfd_in\fP が参照するパイプからファイルディスクリプター \fIfd_out\fP -が参照するパイプへ最大 \fIlen\fP バイトのデータを複製する。 この操作では、複製されるデータは \fIfd_in\fP -からは消費されない。したがって、これらのデータをこの後の \fBsplice\fP(2) でコピーすることができる。 - -\fIflags\fP は一連の修飾フラグであり、 \fBsplice\fP(2) や \fBvmsplice\fP(2) と共通の名前である。 -.TP 1.9i -\fBSPLICE_F_MOVE\fP -現在のところ \fBtee\fP() では何の効果もない。 \fBsplice\fP(2) 参照。 -.TP -\fBSPLICE_F_NONBLOCK\fP -入出力で停止 (block) しない。詳細は \fBsplice\fP(2) 参照。 -.TP -\fBSPLICE_F_MORE\fP -現在のところ \fBtee\fP() では何の効果もないが、将来的には実装される可能性がある。 \fBsplice\fP(2) 参照。 -.TP -\fBSPLICE_F_GIFT\fP -\fBtee\fP() では未使用。 \fBvmsplice\fP(2) 参照。 -.SH 返り値 -成功して完了すると、 \fBtee\fP() は入出力間で複製されたバイト数を返す。 返り値 0 はデータの転送が行われなかったことを示す。 -この場合、処理を停止 (block) しても無意味である。 なぜなら、 \fIfd_in\fP -が参照するパイプの書き込み側に接続されている者がいないからである。 - -エラーの場合、 \fBtee\fP() は \-1 を返し、 \fIerrno\fP にエラーを示す値を設定する。 -.SH エラー -.TP -\fBEAGAIN\fP -\fBSPLICE_F_NONBLOCK\fP が \fIflags\fP に指定されていて、かつ操作が停止するような状態であった。 -.TP -\fBEINVAL\fP -\fIfd_in\fP と \fIfd_out\fP のどちらかがパイプを参照していない。もしくは \fIfd_in\fP と \fIfd_out\fP -が同じパイプを参照している。 -.TP -\fBENOMEM\fP -メモリー不足。 -.SH バージョン -\fBtee\fP() システムコールは Linux 2.6.17 で初めて登場した。 -ライブラリによるサポートは glibc バージョン 2.5 で追加された。 -.SH 準拠 -このシステムコールは Linux 固有である。 -.SH 注意 -概念としては、 \fBtee\fP() は二つのパイプ間でデータのコピーを行う。 しかし、実際には実データのコピーは行われない。 内部では、 -\fBtee\fP() は入力側に対する参照だけを作成することで出力側にデータを 追加する。 -.SH 例 -以下の例は、 \fBtee\fP() システムコールを使って、 基本的な \fBtee\fP(1) プログラムを実装したものである。 以下は利用例である。 - -.in +4n -.nf -$ \fBdate |./a.out out.log | cat\fP -Tue Oct 28 10:06:00 CET 2014 -$ \fBcat out.log\fP -Tue Oct 28 10:06:00 CET 2014 -.fi -.in -.SS プログラムのソース -.nf - -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include - -int -main(int argc, char *argv[]) -{ - int fd; - int len, slen; - - if (argc != 2) { - fprintf(stderr, "Usage: %s \en", argv[0]); - exit(EXIT_FAILURE); - } - - fd = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC, 0644); - if (fd == \-1) { - perror("open"); - exit(EXIT_FAILURE); - } - - do { - /* - * tee stdin to stdout. - */ - len = tee(STDIN_FILENO, STDOUT_FILENO, - INT_MAX, SPLICE_F_NONBLOCK); - - if (len < 0) { - if (errno == EAGAIN) - continue; - perror("tee"); - exit(EXIT_FAILURE); - } else - if (len == 0) - break; - - /* - * Consume stdin by splicing it to a file. - */ - while (len > 0) { - slen = splice(STDIN_FILENO, NULL, fd, NULL, - len, SPLICE_F_MOVE); - if (slen < 0) { - perror("splice"); - break; - } - len \-= slen; - } - } while (1); - - close(fd); - exit(EXIT_SUCCESS); -} -.fi -.SH 関連項目 -\fBsplice\fP(2), \fBvmsplice\fP(2) -.SH この文書について -この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 -である。プロジェクトの説明とバグ報告に関する情報は -http://www.kernel.org/doc/man\-pages/ に書かれている。