diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2020-10-27 21:26:45 +0100 |
---|---|---|
committer | cgzones <cgzones@googlemail.com> | 2020-10-28 19:57:10 +0100 |
commit | 887dfde3082bcb1057a965d365206b2ed3d0263b (patch) | |
tree | 317eadcd0e4c27be8d02740edb080450512a51a2 /Process.h | |
parent | 76797f8d928a9278f7356e270ef07cea1db5510a (diff) |
Implement Process_getParentPid and Process_isChildOf as functions
Make it more readable and fix unenclosed macro arguments
Diffstat (limited to 'Process.h')
-rw-r--r-- | Process.h | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -129,9 +129,13 @@ typedef struct ProcessClass_ { #define As_Process(this_) ((const ProcessClass*)((this_)->super.klass)) -#define Process_getParentPid(process_) (process_->tgid == process_->pid ? process_->ppid : process_->tgid) +static inline pid_t Process_getParentPid(const Process* this) { + return this->tgid == this->pid ? this->ppid : this->tgid; +} -#define Process_isChildOf(process_, pid_) (process_->tgid == pid_ || (process_->tgid == process_->pid && process_->ppid == pid_)) +static inline bool Process_isChildOf(const Process* this, pid_t pid) { + return pid == Process_getParentPid(this); +} #define Process_sortState(state) ((state) == 'I' ? 0x100 : (state)) |