diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-03-27 15:01:02 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-04-11 22:30:04 +0200 |
commit | 342f6f80f532a900667349e6c78c04ecd54ca6dc (patch) | |
tree | b303e6436611fd983c2adce4e59af73b45ebc753 /src/basic/process-util.h | |
parent | 1ce360813decc3ddc6dfff8c1f55927e83021404 (diff) | |
download | systemd-342f6f80f532a900667349e6c78c04ecd54ca6dc.tar.gz systemd-342f6f80f532a900667349e6c78c04ecd54ca6dc.tar.bz2 systemd-342f6f80f532a900667349e6c78c04ecd54ca6dc.zip |
process-util: add TAKE_PID(), similar to TAKE_PTR/TAKE_FD, but for child process PIDs
Diffstat (limited to 'src/basic/process-util.h')
-rw-r--r-- | src/basic/process-util.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/basic/process-util.h b/src/basic/process-util.h index e862dbb9ab..49d28cdf40 100644 --- a/src/basic/process-util.h +++ b/src/basic/process-util.h @@ -191,3 +191,11 @@ int fork_agent(const char *name, const int except[], unsigned n_except, pid_t *p #endif assert_cc(TASKS_MAX <= (unsigned long) PID_T_MAX) + +/* Like TAKE_PTR() but for child PIDs, resetting them to 0 */ +#define TAKE_PID(pid) \ + ({ \ + pid_t _pid_ = (pid); \ + (pid) = 0; \ + _pid_; \ + }) |