process-util: add TAKE_PID(), similar to TAKE_PTR/TAKE_FD, but for child process...
authorLennart Poettering <lennart@poettering.net>
Tue, 27 Mar 2018 13:01:02 +0000 (15:01 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 11 Apr 2018 20:30:04 +0000 (22:30 +0200)
src/basic/process-util.h

index e862dbb..49d28cd 100644 (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_;                          \
+        })