|KCMP(2)||Linux Programmer's Manual||KCMP(2)|
NAMEkcmp - compare two processes to determine if they share a kernel resource
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.
DESCRIPTIONThe 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.
- Check whether a file descriptor idx1 in the process pid1 refers to the same open file description (see open(2)) as file descriptor idx2 in the process pid2.
- Check whether the process share the same set of open file descriptors. The arguments idx1 and idx2 are ignored.
- Check whether the processes share the same file system information (i.e., file mode creation mask, working directory, and file system root). The arguments idx1 and idx2 are ignored.
- Check whether the processes share I/O context. The arguments idx1 and idx2 are ignored.
- Check whether the processes share the same table of signal dispositions. The arguments idx1 and idx2 are ignored.
- Check whether the processes share the same list of System V semaphore undo operations. The arguments idx1 and idx2 are ignored.
- Check whether the processes share the same address space. The arguments idx1 and idx2 are ignored.
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.
RETURN VALUEThe 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).
- v1 is equal to v2; in other words, the two processes share the resource.
- v1 is less than v2.
- v1 is greater than v2.
- v1 is not equal to v2, but ordering information is unavailable.
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.
- type is KCMP_FILE and fd1 or fd2 is not an open file descriptor.
- type is invalid.
- Insufficient permission to inspect process resources. The CAP_SYS_PTRACE capability is required to inspect processes that you do not own.
- Process pid1 or pid2 does not exist.
VERSIONSThe kcmp() system call first appeared in Linux 3.5.
CONFORMING TOkcmp() is Linux specific and should not be used in programs intended to be portable.
NOTESGlibc does not provide a wrapper for this system call; call it using syscall(2).
SEE ALSOclone(2), unshare(2)
COLOPHONThis page is part of release 3.53 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/.