This is an automated email from the git hooks/post-receive script.
git pushed a commit to reference refs/pull/34/head
in repository terminology.
View the commit online.
commit 1c117c14d649e17f7b927d0c0625fc2e073818bb
Author: [email protected] <[email protected]>
AuthorDate: Sun Mar 29 21:31:45 2026 -0600
feat: assign unique term_id and export TERMINOLOGY_ID env var
Each terminal gets a random uint32 ID at creation, exported as
TERMINOLOGY_ID to child processes. This allows tytab to identify
which terminal it runs in when connecting to the IPC socket.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
---
src/bin/termio.c | 2 +-
src/bin/termpty.c | 10 +++++++++-
src/bin/termpty.h | 2 +-
src/bin/win.c | 35 +++++++++++++++++++++++++++++++++++
src/bin/win.h | 2 ++
5 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/src/bin/termio.c b/src/bin/termio.c
index 1d8dc987..646c8368 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -4288,7 +4288,7 @@ termio_add(Evas_Object *win, Config *config,
window_id = elm_win_window_id_get(win);
sd->pty = termpty_new(cmd, login_shell, cd, w, h, config, title,
- window_id);
+ window_id, term_id_get(term));
if (!sd->pty)
{
ERR(_("Could not allocate termpty"));
diff --git a/src/bin/termpty.c b/src/bin/termpty.c
index d1e00283..e9e0a633 100644
--- a/src/bin/termpty.c
+++ b/src/bin/termpty.c
@@ -535,7 +535,7 @@ _is_shell_valid(const char *cmd)
Termpty *
termpty_new(const char *cmd, Eina_Bool login_shell, const char *cd,
int w, int h, Config *config, const char *title,
- Ecore_Window window_id)
+ Ecore_Window window_id, uint32_t term_id)
{
Termpty *ty;
const char *pty;
@@ -789,6 +789,14 @@ termpty_new(const char *cmd, Eina_Bool login_shell, const char *cd,
snprintf(buf, sizeof(buf), "WINDOWID=%lu", (unsigned long)window_id);
putenv(buf);
}
+ if (term_id)
+ {
+ char buf[256];
+
+ snprintf(buf, sizeof(buf), "TERMINOLOGY_ID=%u",
+ (unsigned int)term_id);
+ putenv(strdup(buf));
+ }
#if ((EFL_VERSION_MAJOR > 1) || (EFL_VERSION_MINOR >= 24)) || ((EFL_VERSION_MAJOR == 1) && (EFL_VERSION_MINOR == 23) && (EFL_VERSION_MICRO == 99))
eina_file_close_from(3, NULL);
#endif
diff --git a/src/bin/termpty.h b/src/bin/termpty.h
index d802a0e3..d99222d4 100644
--- a/src/bin/termpty.h
+++ b/src/bin/termpty.h
@@ -289,7 +289,7 @@ void termpty_shutdown(void);
Termpty *termpty_new(const char *cmd, Eina_Bool login_shell, const char *cd,
int w, int h, Config *config, const char *title,
- Ecore_Window window_id);
+ Ecore_Window window_id, uint32_t term_id);
void termpty_free(Termpty *ty);
void termpty_config_update(Termpty *ty, Config *config);
diff --git a/src/bin/win.c b/src/bin/win.c
index 6981b1a7..40842057 100644
--- a/src/bin/win.c
+++ b/src/bin/win.c
@@ -1,6 +1,9 @@
#include "private.h"
#include <assert.h>
+#include <stdint.h>
+#include <fcntl.h>
+#include <unistd.h>
#include <Elementary.h>
#include <Elementary_Cursor.h>
#include <Ecore_Input.h>
@@ -142,6 +145,7 @@ struct tag_Term
} down;
double last_keypress_time; /* for anti-bombing, updated on key-down */
Eina_Bool tytab_frozen; /* one-way latch: once set, tytab disabled forever */
+ uint32_t term_id; /* unique ID for IPC nonce matching */
int refcnt;
unsigned char hold : 1;
unsigned char unswallowed : 1;
@@ -6586,6 +6590,29 @@ _container_find_by_name(Term_Container *tc, Eina_Stringshare *name)
}
}
+static uint32_t
+_term_id_generate(void)
+{
+ uint32_t id;
+ int fd;
+
+ fd = open("/dev/urandom", O_RDONLY);
+ if (fd < 0) return 0;
+
+ do
+ {
+ if (read(fd, &id, sizeof(id)) != sizeof(id))
+ {
+ close(fd);
+ return 0;
+ }
+ }
+ while (id == 0);
+
+ close(fd);
+ return id;
+}
+
static void
_cb_command(void *data,
Evas_Object *_obj EINA_UNUSED,
@@ -7606,6 +7633,13 @@ term_termio_get(const Term *term)
return term->termio;
}
+uint32_t
+term_id_get(const Term *term)
+{
+ if (!term) return 0;
+ return term->term_id;
+}
+
Evas_Object *
term_miniview_get(const Term *term)
{
@@ -7709,6 +7743,7 @@ term_new(Win *wn, Config *config, const char *cmd,
term->wn = wn;
term->hold = hold;
term->config = config;
+ term->term_id = _term_id_generate();
term->core = o = elm_layout_add(wn->win);
theme_apply(o, term->config, "terminology/core", NULL, NULL, EINA_TRUE);
diff --git a/src/bin/win.h b/src/bin/win.h
index bac95987..f242fff7 100644
--- a/src/bin/win.h
+++ b/src/bin/win.h
@@ -2,6 +2,7 @@
#define TERMINOLOGY_WIN_H_ 1
#include "config.h"
+#include <stdint.h>
typedef struct tag_Win Win;
typedef struct tag_Term Term;
@@ -74,6 +75,7 @@ term_imf_context_get(Term *term);
Eina_Bool term_is_visible(const Term *term);
Eina_Bool term_is_focused(const Term *term);
+uint32_t term_id_get(const Term *term);
void win_font_size_set(Win *wn, int new_size);
void win_font_update(Term *term);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.