[igt-dev] [PATCH i-g-t v4 8/9] lib/igt_kmod: properly handle pipewire-pulse

Andi Shyti andi.shyti at linux.intel.com
Tue May 17 10:34:50 UTC 2022


Hi Mauro,

> +static void pipewire_reserve_wait(int pipewire_pulse_pid)
> +{
> +	char xdg_dir[PATH_MAX];
> +	const char *homedir;
> +	struct passwd *pw;
> +	proc_t *proc_info;
> +	PROCTAB *proc;
> +
> +	igt_fork(child, 1) {
> +		igt_info("Preventing pipewire-pulse to use the audio drivers\n");
> +
> +		proc = openproc(PROC_FILLCOM | PROC_FILLSTAT | PROC_FILLARG);
> +		igt_assert(proc != NULL);
> +
> +		while ((proc_info = readproc(proc, NULL))) {
> +			if (pipewire_pulse_pid == proc_info->tid)
> +				break;
> +			freeproc(proc_info);
> +		}
> +		closeproc(proc);
> +
> +		/* Sanity check: if it can't find the process, it means it has gone */
> +		if (pipewire_pulse_pid != proc_info->tid)
> +			exit(0);
> +
> +		pw = getpwuid(proc_info->euid);
> +		homedir = pw->pw_dir;
> +		snprintf(xdg_dir, sizeof(xdg_dir), "/run/user/%d", proc_info->euid);
> +		setgid(proc_info->egid);
> +		setuid(proc_info->euid);
> +		clearenv();
> +		setenv("HOME", homedir, 1);
> +		setenv("XDG_RUNTIME_DIR",xdg_dir, 1);
> +		freeproc(proc_info);
> +
> +		/*
> +		 * pw-reserve will run in background. It will only exit when
> +		 * igt_kill_children() is called later on. So, it shouldn't
> +		 * call igt_waitchildren(). Instead, just exit with the return
> +		 * code from pw-reserve.
> +		 */
> +		exit(system("pw-reserve -n Audio0 -r"));

Thanks for the comment! And I also think think it's safe!

igt_fork() calls exit() anyway but you call it earlier, so that
the former will not have time to be called.

Reviewed-by: Andi Shyti <andi.shyti at linux.intel.com>

Thanks,
Andi


More information about the igt-dev mailing list