QUARK_QUEUE_GET_EVENTS(3) Library Functions Manual QUARK_QUEUE_GET_EVENTS(3)

quark_queue_get_eventsmain quark driver

#include <quark.h>

int
quark_queue_get_events(struct quark_queue *qq, struct quark_event *qev, int nqev);

quark_queue_get_events fills the array of events pointed to by qev to a maximum of neqv entries.

This function is the main driver of quark. Quark doesn't create threads or introduces hidden control flows, all its state is mutated through this function call. For a better explanation of quark's design, refer to quark(7). A summary of what this function does:

A quark_event is defined as:

struct quark_event {
	u64				 events;
	const struct quark_process	*process;
};
A bitmask representing the events that originated this quark_event:
New process, result of a fork.
Process changed image, result of an exec.
Process exited.
Process changed its name (COMM).

It's important to note that events is what triggered the event, not what is known about the process.

It might also be more than one value as events get aggregated. For example, a short lived process will have the following mask: QUARK_EV_FORK | | .

A pointer to the process which originated the event. struct quark_process is defined as:
struct quark_process {
	u32	pid;
	u64	flags;
	/* QUARK_F_PROC */
	u64	proc_cap_inheritable;
	u64	proc_cap_permitted;
	u64	proc_cap_effective;
	u64	proc_cap_bset;
	u64	proc_cap_ambient;
	u64	proc_time_boot;
	u32	proc_ppid;
	u32	proc_uid;
	u32	proc_gid;
	u32	proc_suid;
	u32	proc_sgid;
	u32	proc_euid;
	u32	proc_egid;
	u32	proc_pgid;
	u32	proc_sid;
	u32	proc_tty_major;
	u32	proc_tty_minor;
	u32	proc_entry_leader_type;
	u32	proc_entry_leader;
	/* QUARK_F_EXIT */
	s32	exit_code;
	u64	exit_time_event;
	/* QUARK_F_COMM */
	char	comm[16];
	/* QUARK_F_FILENAME */
	char	filename[1024];
	/* QUARK_F_CMDLINE */
	size_t	cmdline_len;
	char	cmdline[1024];
	/* QUARK_F_CWD */
	char	cwd[1024];
};

represent the fields which are known about the process, these can be cached and originate from previous events. Each bit in the set represents one or more members of the structure, if the bit is unset, the respective members are invalid/unknown.

members are valid.
is valid.
is valid.
is valid.
and are valid.
is valid.

process points to internal data, it be modified and/or stored. In the case of multithreading, the pointer should not be accessed concurrently with another thread which executes quark_queue_get_events.

In other words, read the stuff you want, copy it out, and forget about it.

The number of filled events via qev to a maximum of nqev. If zero is returned, the user should consider calling quark_queue_block(3). In the case of an internal error, -1 is returned and errno is set.

quark_event_dump(3), quark_process_lookup(3), quark_queue_block(3), quark_queue_close(3), quark_queue_default_attr(3), quark_queue_get_epollfd(3), quark_queue_get_stats(3), quark_queue_open(3), quark(7), quark-btf(8), quark-mon(8), quark-test(8)

October 25, 2024 Linux