1 .\" Copyright (C) 2012, Cyrill Gorcunov <gorcunov@openvz.org>
2 .\" and Copyright (C) 2012, Michael Kerrisk <mtk.manpages@gmail.com>
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.
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.
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
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
26 .\" Kernel commit d97b46a64674a267bc41c9e16132ee2a98c3347d
28 .TH KCMP 2 2013-12-08 "Linux" "Linux Programmer's Manual"
30 kcmp \- compare two processes to determine if they share a kernel resource
33 .B #include <linux/kcmp.h>
35 .BI "int kcmp(pid_t " pid1 ", pid_t " pid2 ", int " type ,
36 .BI " unsigned long " idx1 ", unsigned long " idx2 );
40 There is no glibc wrapper for this system call; see NOTES.
44 system call can be used to check whether the two processes identified by
48 share a kernel resource such as virtual memory, file descriptors,
53 argument specifies which resource is to be compared in the two processes.
54 It has one of the following values:
57 Check whether a file descriptor
61 refers to the same open file description (see
69 Check whether the process share the same set of open file descriptors.
77 Check whether the processes share the same filesystem information
78 (i.e., file mode creation mask, working directory, and filesystem root).
86 Check whether the processes share I/O context.
94 Check whether the processes share the same table of signal dispositions.
102 Check whether the processes share the same
103 list of System\ V semaphore undo operations.
111 Check whether the processes share the same address space.
120 is not protected against false positives which may occur if tasks are
122 One should stop tasks by sending
126 prior to inspection with this system call to obtain meaningful results.
128 The return value of a successful call to
130 is simply the result of arithmetic comparison
131 of kernel pointers (when the kernel compares resources, it uses their
134 The easiest way to explain is to consider an example.
139 are the addresses of appropriate resources, then the return value
140 is one of the following:
146 in other words, the two processes share the resource.
159 but ordering information is unavailable.
162 On error, \-1 is returned, and
164 is set appropriately.
167 was designed to return values suitable for sorting.
168 This is particularly handy if one needs to compare
169 a large number of file descriptors.
180 is not an open file descriptor.
187 Insufficient permission to inspect process resources.
190 capability is required to inspect processes that you do not own.
201 system call first appeared in Linux 3.5.
204 is Linux-specific and should not be used in programs intended to be portable.
206 Glibc does not provide a wrapper for this system call; call it using
209 This system call is available only if the kernel was configured with
210 .BR CONFIG_CHECKPOINT_RESTORE .
211 The main use of the system call is for the
212 checkpoint/restore in user space (CRIU) feature.
213 The alternative to this system call would have been to expose suitable
214 process information via the
216 filesystem; this was deemed to be unsuitable for security reasons.
220 for some background information on the shared resources
221 referred to on this page.
226 This page is part of release 3.79 of the Linux
229 A description of the project,
230 information about reporting bugs,
231 and the latest version of this page,
233 \%http://www.kernel.org/doc/man\-pages/.