diff --git a/tools/meson.build b/tools/meson.build index af68c6e..60025d3 100644 --- a/tools/meson.build +++ b/tools/meson.build @@ -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], ) diff --git a/tools/oeffis-demo-tool.c b/tools/oeffis-demo-tool.c index 99f90ad..11e26ce 100644 --- a/tools/oeffis-demo-tool.c +++ b/tools/oeffis-demo-tool.c @@ -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: