I'm looking for a way to transparently freeze (pause) a process and then unfreeze it later. This is possible with
SIGSTOP causes the parent to be notified (by returning from
waitpid), which e.g. causes bash to put interactive processes into the background (the problems with that approach are described in more detail in this link).
cgroup subsystem has a way to accomplish this by writing to files in
/sys/fs/cgroup/freezer/, but that only applies at the cgroup level – that is, you can only freeze an entire group of processes/threads at a time. I suppose one could get around this by arranging to place each process in its own cgroup, but that seems like a fair bit of hassle, and possibly dangerous since
systemd et al. are already using
cgroups for their own purposes.
I'm pretty close to just writing a kernel module that exposes the underlying
freeze_task API to userspace, but I'd really like to avoid doing that if possible!