From 342f6f80f532a900667349e6c78c04ecd54ca6dc Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 27 Mar 2018 15:01:02 +0200 Subject: [PATCH] process-util: add TAKE_PID(), similar to TAKE_PTR/TAKE_FD, but for child process PIDs --- src/basic/process-util.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/basic/process-util.h b/src/basic/process-util.h index e862dbb..49d28cd 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_; \ + }) -- 2.7.4