commit 92165e8e75b4ea9dc382fb3096cdc3fc4f87f064
parent f518a1d404813c9bb423682c14a0d859f73737a2
Author: e-zk <58356365+e-zk@users.noreply.github.com>
Date: Wed, 9 Dec 2020 15:04:05 +1000
merge while loops
Diffstat:
M | after.c | | | 24 | +++++++++--------------- |
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/after.c b/after.c
@@ -119,7 +119,6 @@ main(int argc, char *argv[])
exit(1);
}
-
// initialise virtual memory access
kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, errbuf);
if (kd == NULL)
@@ -128,20 +127,15 @@ main(int argc, char *argv[])
// get initial process list
kinfo = get_proc_list(kd, &entries);
- // if a process name is given use that, otherwise use pid
- if (pname != NULL) {
- while(pname_is_in(pname, kinfo, entries) == 0) {
- kinfo = get_proc_list(kd, &entries);
- debug_print("waiting...");
- sleep(1);
- }
- }
- else {
- while(pid_is_in(pid, kinfo, entries) == 0) {
- kinfo = get_proc_list(kd, &entries);
- debug_print("waiting...");
- sleep(1);
- }
+ // if a process name is given use that function, otherwise use pid function
+ while (
+ (pname != NULL) ?
+ pname_is_in(pname, kinfo, entries) == 0 :
+ pid_is_in(pid, kinfo, entries) == 0
+ ) {
+ kinfo = get_proc_list(kd, &entries);
+ debug_print("waiting...");
+ sleep(1);
}