4 static TAILQ_HEAD(, trace_proc
) proc_root
;
5 static unsigned int nr_procs
;
8 * Initialize the list of traced processes.
14 TAILQ_INIT(&proc_root
);
19 * Add a new process to the list of traced processes, allocating memory for it
20 * first. Return the new process structure with its PID assigned and the rest
21 * zeroed out, or NULL upon allocation failure (with errno set appropriately).
26 struct trace_proc
*proc
;
28 proc
= (struct trace_proc
*)malloc(sizeof(struct trace_proc
));
33 memset(proc
, 0, sizeof(*proc
));
37 TAILQ_INSERT_TAIL(&proc_root
, proc
, next
);
44 * Retrieve the data structure for a traced process based on its PID. Return
45 * a pointer to the structure, or NULL if no structure exists for this process.
50 struct trace_proc
*proc
;
52 /* Linear search for now; se we can easily add a hashtable later.. */
53 TAILQ_FOREACH(proc
, &proc_root
, next
) {
62 * Remove a process from the list of traced processes.
65 proc_del(struct trace_proc
* proc
)
68 TAILQ_REMOVE(&proc_root
, proc
, next
);
75 * Iterator for the list of traced processes. If a NULL pointer is given,
76 * return the first process in the list; otherwise, return the next process in
77 * the list. Not stable with respect to list modifications.
80 proc_next(struct trace_proc
* proc
)
84 return TAILQ_FIRST(&proc_root
);
86 return TAILQ_NEXT(proc
, next
);
90 * Return the number of processes in the list of traced processes.