QUARK_QUEUE_GET_EVENT(3) Library Functions Manual QUARK_QUEUE_GET_EVENT(3)

quark_queue_get_eventmain quark driver

#include <quark.h>

const struct quark_event *
quark_queue_get_event(struct quark_queue *qq);

quark_queue_get_event returns a pointer to the next quark_event, or NULL if there isn't any.

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;
	u32	proc_uts_inonum;
	u32	proc_ipc_inonum;
	u32	proc_mnt_inonum;
	u32	proc_net_inonum;
	/* 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.

The returned quark_event pointer as well as the process member point to internal data, they be modified and/or stored. In the case of multithreading, the pointers should not be accessed concurrently with another running quark_queue_get_event.

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

A pointer to quark_event. If there aren't events, NULL is returned and the user should consider calling quark_queue_block(3).

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)

December 1, 2024 Linux