OSDN Git Service

069f59929fc1e646007d8e8dc18b2e66f4d5cf8f
[linuxjm/LDP_man-pages.git] / draft / man2 / kcmp.2
1 .\" Copyright (C) 2012, Cyrill Gorcunov <gorcunov@openvz.org>
2 .\" and Copyright (C) 2012, Michael Kerrisk <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of
10 .\" this manual under the conditions for verbatim copying, provided that
11 .\" the entire resulting derived work is distributed under the terms of
12 .\" a permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume
16 .\" no responsibility for errors or omissions, or for damages resulting
17 .\" from the use of the information contained herein.  The author(s) may
18 .\" not have taken the same level of care in the production of this
19 .\" manual, which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .\" Kernel commit d97b46a64674a267bc41c9e16132ee2a98c3347d
27 .\"
28 .\"*******************************************************************
29 .\"
30 .\" This file was generated with po4a. Translate the source file.
31 .\"
32 .\"*******************************************************************
33 .\"
34 .\" Japanese Version Copyright (c) 2013  Akihiro MOTOKI
35 .\"         all rights reserved.
36 .\" Translated 2013-08-21, Akihiro MOTOKI <amotoki@gmail.com>
37 .\" 
38 .TH KCMP 2 2013\-01\-27 Linux "Linux Programmer's Manual"
39 .SH 名前
40 kcmp \- 二つのプロセスが同じカーネルリソースを共有しているかを比較する
41 .SH 書式
42 .nf
43 \fB#include <linux/kcmp.h>\fP
44
45 \fBint kcmp(pid_t \fP\fIpid1\fP\fB, pid_t \fP\fIpid2\fP\fB, int \fP\fItype\fP\fB,\fP
46 \fB         unsigned long \fP\fIidx1\fP\fB, unsigned long \fP\fIidx2\fP\fB);\fP
47 .fi
48
49 \fI注\fP: このシステムコールには glibc のラッパー関数は存在しない。「注意」の節を参照。
50 .SH 説明
51 システムコール \fBkcmp\fP() を使うと、 ID が \fIpid1\fP と \fIpid2\fP の二つのプロセスが、
52 仮想メモリやファイルディスクリプタなどの、 同じカーネルリソースを共有しているかどうかを検査できる。
53
54 \fItype\fP 引き数は 2 つのプロセス間でどのリソースを比較するかを指定する。 以下のいずれかの値を指定する。
55 .TP 
56 \fBKCMP_FILE\fP
57 プロセス \fIpid1\fP のファイルディスクリプタ \fIidx1\fP が、 プロセス \fIpid2\fP のファイルディスクリプタ \fIidx2\fP
58 と同じオープンファイル記述 (open file description) を参照しているかを検査する。
59 .TP 
60 \fBKCMP_FILES\fP
61 二つのプロセスが同じオープンファイル記述の集合を共有しているかを検査する。 引き数 \fIidx1\fP と \fIidx2\fP は無視される。
62 .TP 
63 \fBKCMP_FS\fP
64 Check whether the processes share the same filesystem information (i.e.,
65 file mode creation mask, working directory, and filesystem root).  The
66 arguments \fIidx1\fP and \fIidx2\fP are ignored.
67 .TP 
68 \fBKCMP_IO\fP
69 二つのプロセスが I/O コンテキストを共有しているかを検査する。 引き数 \fIidx1\fP と \fIidx2\fP は無視される。
70 .TP 
71 \fBKCMP_SIGHAND\fP
72 二つのプロセスがシグナル配送 (disposition) テーブルを共有しているかを検査する。 引き数 \fIidx1\fP と \fIidx2\fP
73 は無視される。
74 .TP 
75 \fBKCMP_SYSVSEM\fP
76 二つのプロセスが同じ System V セマフォ undo 操作のリストを共有しているかを検査する。 引き数 \fIidx1\fP と \fIidx2\fP
77 は無視される。
78 .TP 
79 \fBKCMP_VM\fP
80 二つのプロセスが同じアドレス空間を共有しているかを検査する。 引き数 \fIidx1\fP と \fIidx2\fP は無視される。
81 .PP
82 \fBkcmp\fP() には、タスクが実行されている場合に起こり得る誤判定 (false positive) に関する保護はない。 ということは、
83 意味のある結果を得るためには、 このシステムコールで検査されているタスクを停止すべきだということだ。
84 .SH 返り値
85 \fBkcmp\fP() の呼び出しが成功した場合の返り値は、単にカーネルポインタを数値で比較した結果となる
86 (カーネルはリソースを比較する際、リソースのメモリアドレスを使用する)。
87
88 これを説明するには、例を見るのが一番簡単である。 \fIv1\fP と \fIv2\fP を適切なリソースのアドレスとすると、 返り値は以下のいずれか一つとなる。
89 .RS 4
90 .IP 0 4
91 \fIv1\fP は \fIv2\fP と等しい。言い換えれば、二つのプロセスはそのリソースを共有している。
92 .IP 1
93 \fIv1\fP は \fIv2\fP より小さい。
94 .IP 2
95 \fIv1\fP は \fIv2\fP より大きい。
96 .IP 3
97 \fIv1\fP は \fIv2\fP と等しくないが、順序情報がない。
98 .RE
99 .PP
100 エラーの場合は \-1 が返され、 \fIerrno\fP が適切に設定される。
101
102 \fBkcmp ()\fP は、ソートに適した値を返すように設計された。 大量のファイルディスクリプタを比較する必要がある場合に、特に役に立つ。
103 .SH エラー
104 .TP 
105 \fBEBADF\fP
106 \fItype\fP が \fBKCMP_FILE\fP で、かつ \fIfd1\fP か \fIfd2\fP がオープンファイル記述でない。
107 .TP 
108 \fBEINVAL\fP
109 \fItype\fP が無効である。
110 .TP 
111 \fBEPERM\fP
112 プロセスのリソースを検査するのに十分な許可がない。 自分が所有していないプロセスを検査するためには \fBCAP_SYS_PTRACE\fP
113 ケーパビリティが必要である。
114 .TP 
115 \fBESRCH\fP
116 プロセス \fIpid1\fP か \fIpid2\fP が存在しない。
117 .SH バージョン
118 \fBkcmp\fP() システムコールは Linux 3.5 で初めて登場した。
119 .SH 準拠
120 \fBkcmp\fP() は Linux 特有であり、 移植を考慮したプログラムでは使用すべきではない。
121 .SH 注意
122 glibc はこのシステムコールに対するラッパー関数を提供していない。 \fBsyscall\fP(2) を使って呼び出すこと。
123
124 This system call is available only if the kernel was configured with
125 \fBCONFIG_CHECKPOINT_RESTORE\fP.  The main use of the system call is for the
126 checkpoint/restore in user space (CRIU) feature.  The alternative to this
127 system call would have been to expose suitable process information via the
128 \fBproc\fP(5)  filesystem; this was deemed to be unsuitable for security
129 reasons.
130
131 このページで参照されている共有リソースに関する背景についての情報は \fBclone\fP(2) を参照のこと。
132 .SH 関連項目
133 \fBclone\fP(2), \fBunshare\fP(2)
134 .SH この文書について
135 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.54 の一部
136 である。プロジェクトの説明とバグ報告に関する情報は
137 http://www.kernel.org/doc/man\-pages/ に書かれている。