chiark / gitweb /
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)
committerSven Eden <yamakuzure@gmx.net>
Fri, 24 Aug 2018 14:47:08 +0000 (16:47 +0200)
src/basic/process-util.h

index eff42d0533201a7dca3fc93b1be3125e4b234af0..ee094932a371b41b68d84859da1961bc86776e84 100644 (file)
@@ -209,3 +209,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_;                          \
+        })