process-util: rework TAKE_PID() to be side-effect free

This commit is contained in:
Lennart Poettering
2021-11-03 15:57:02 +01:00
parent 2c1612100d
commit 883946f0d2
+3 -2
View File
@@ -192,8 +192,9 @@ 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_t *_ppid_ = &(pid); \
pid_t _pid_ = *_ppid_; \
*_ppid_ = 0; \
_pid_; \
})