History

pid: add pidfd_open()

This adds the pidfd_open() syscall. It allows a caller to retrieve pollable pidfds for a process which did not get created via CLONE_PIDFD, i.e. for a process that is created via traditional fork()/clone() calls that is only referenced by a PID: int pidfd = pidfd_open(1234, 0); ret = pidfd_send_signal(pidfd, SIGSTOP, NULL, 0); With the introduction of pidfds through CLONE_PIDFD it is possible to created pidfds at process creation time. However, a lot of processes get created with traditional PID-based calls such as fork() or clone() (without CLONE_PIDFD). For these processes a caller can currently not create a pollable pidfd. This is a problem for Android's low memory killer (LMK) and service managers such as systemd. Both are examples of tools that want to make use of pidfds to get reliable notification of process exit for non-parents (pidfd polling) and race-free signal sending (pidfd_send_signal()). They intend to switch to this API for process supervision/management as soon as possible. Having no way to get pollable pidfds from PID-only processes is one of the biggest blockers for them in adopting this api. With pidfd_open() making it possible to retrieve pidfds for PID-based processes we enable them to adopt this api. In line with Arnd's recent changes to consolidate syscall numbers across architectures, I have added the pidfd_open() syscall to all architectures at the same time.

Christian Brauner committed 7 years ago

Commit 32fcb421 parent 740378d2 files · +70 −0Browse files

Showing the changes to include/linux (1 of 2 files). Show all

Unified · Split

include/linux/syscalls.h+1−0
@@ -929,6 +929,7 @@ asmlinkage long sys_clock_adjtime32(clockid_t which_clock, · 928 unmodified lines
929929 struct old_timex32 __user *tx);
930930 asmlinkage long sys_syncfs(int fd);
931931 asmlinkage long sys_setns(int fd, int nstype);
932+asmlinkage long sys_pidfd_open(pid_t pid, unsigned int flags);
932933 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
933934 unsigned int vlen, unsigned flags);
934935 asmlinkage long sys_process_vm_readv(pid_t pid,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t