process-util: add TAKE_PID(), similar to TAKE_PTR/TAKE_FD, but for child process PIDs

This commit is contained in:
Lennart Poettering
2018-04-11 22:30:04 +02:00
parent 1ce360813d
commit 342f6f80f5
+8
View File
@@ -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_; \
})