tools: start ei-debug-events for the fd we get from the oeffis demo tool

Once we get the fd, fork off ei-debug-events for that fd so we can debug
what the EIS implementation actually sends us.
This commit is contained in:
Peter Hutterer 2023-08-31 09:37:40 +10:00
parent 8713ef2d63
commit ac16ba77ff
2 changed files with 22 additions and 1 deletions

View file

@ -34,6 +34,7 @@ executable('ei-debug-events',
if build_oeffis
executable('oeffis-demo-tool',
'oeffis-demo-tool.c',
c_args: ['-DMESON_BUILDDIR="@0@"'.format(meson.current_build_dir())],
include_directories: [inc_builddir],
dependencies: [dep_libutil, dep_liboeffis],
)

View file

@ -40,6 +40,10 @@
#include "liboeffis.h"
#ifndef MESON_BUILDDIR
#error MESON_BUILDDIR must be defined
#endif
DEFINE_UNREF_CLEANUP_FUNC(oeffis);
static bool stop = false;
@ -48,6 +52,21 @@ static void sighandler(int signal) {
stop = true;
}
static void start_debug_events(int fd)
{
pid_t pid = fork();
assert(pid != -1);
if (pid == 0) {
_cleanup_free_ char *fdstr = xaprintf("%d", fd);
execl(MESON_BUILDDIR "/ei-debug-events",
"ei-debug-events",
"--socketfd", fdstr, NULL);
fprintf(stderr, "Failed to fork: %m\n");
exit(1);
}
}
int main(int argc, char **argv)
{
_unref_(oeffis) *oeffis = oeffis_new(NULL);
@ -71,7 +90,7 @@ int main(int argc, char **argv)
break;
case OEFFIS_EVENT_CONNECTED_TO_EIS: {
_cleanup_close_ int eisfd = oeffis_get_eis_fd(oeffis);
printf("We have an eisfd: lucky number %d\n", eisfd);
printf("# We have an eisfd: lucky number %d\n", eisfd);
/* Note: unless we get closed/disconnected, we are
* started now, or will be once the compositor is
* happy with it.
@ -84,6 +103,7 @@ int main(int argc, char **argv)
* cause the compositor or the portal to invalidate
* our EIS fd.
*/
start_debug_events(eisfd);
break;
}
case OEFFIS_EVENT_DISCONNECTED: