kcmp
compare two processes to determine if they share a kernel resource
- Provided by: manpages-dev (Version: 3.54-1ubuntu1)
- Source: manpages
- Report a bug
compare two processes to determine if they share a kernel resource
#include <linux/kcmp.h>
int kcmp(pid_t pid1, pid_t pid2, int type,
unsigned long idx1, unsigned long idx2);
Note: There is no glibc wrapper for this system call; see NOTES.
The kcmp() system call can be used to check whether the two processes identified by pid1 and pid2 share a kernel resource such as virtual memory, file descriptors, and so on.
The type argument specifies which resource is to be compared in the two processes. It has one of the following values:
Note the kcmp() is not protected against false positives which may have place if tasks are running. Which means one should stop tasks being inspected with this syscall to obtain meaningful results.
The return value of a successful call to kcmp() is simply the result of arithmetic comparison of kernel pointers (when the kernel compares resources, it uses their memory addresses).
The easiest way to explain is to consider an example. Suppose that v1 and v2 are the addresses of appropriate resources, then the return value is one of the following:
On error, -1 is returned, and errno is set appropriately.
kcmp () was designed to return values suitable for sorting. This is particularly handy if one needs to compare a large number of file descriptors.
The kcmp() system call first appeared in Linux 3.5.
kcmp() is Linux specific and should not be used in programs intended to be portable.
Glibc does not provide a wrapper for this system call; call it using syscall(2).
This system call is available only if the kernel was configured with CONFIG_CHECKPOINT_RESTORE. The main use of the system call is for the checkpoint/restore in user space (CRIU) feature. The alternative to this system call would have been to expose suitable process information via the proc(5) filesystem; this was deemed to be unsuitable for security reasons.
See clone(2) for some background information on the shared resources referred to on this page.
This page is part of release 3.54 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/.