--- /dev/null
+/*
+ * Copyright (C) 2017 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License, version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <common/compat/getenv.h>
+#include <common/consumer/consumer.h>
+#include <common/error.h>
+#include <unistd.h>
+#include <stdbool.h>
+#include <lttng/constant.h>
+#include <fcntl.h>
+#include <dlfcn.h>
+#include <assert.h>
+#include <stdio.h>
+
+#include <bin/lttng-relayd/connection.h>
+
+int lttng_opt_verbose;
+int lttng_opt_mi;
+int lttng_opt_quiet;
+
+int __testpoint_relayd_viewer_session_attach(void)
+{
+ int ret = 0;
+ const char *state_file_path;
+ int state_fd = -1;
+
+ state_file_path = lttng_secure_getenv(
+ "RELAYD_STATE_PATH");
+ if (!state_file_path) {
+ ERR("RELAYD_STATE_PATH getenv");
+ ret = -1;
+ goto end;
+ }
+
+ state_fd = open(state_file_path, O_WRONLY | O_APPEND | O_SYNC);
+ if (state_fd == -1) {
+ ERR("RELAYD_STATE_PATH open");
+ ret = -1;
+ goto end;
+ }
+
+ dprintf(state_fd, "Viewer attached\n");
+end:
+ if(state_fd > -1) {
+ (void) close(state_fd);
+ }
+ return ret;
+}