dvtm

dynamic virtual terminal manager - with my changes
git clone https://pi.duncano.de/git/dvtm.git
Log | Files | Refs | README | LICENSE

commit e2074b724c6c96f0ca760fa4db17a44ad2076f71
parent c43b0ae9950250db11fd253a07db7980d9b27ce1
Author: Marc Andre Tanner <mat@brain-dump.org>
Date:   Mon, 16 Jun 2008 17:50:16 +0200

Extend clients with a unique id and export it to child processes

The generated id is passed to clients in an environment variable called
DVTM_WINDOW_ID.

This is only enabled if CONFIG_CMDFIFO is defined.

Diffstat:
cmdfifo.c | 1+
dvtm.c | 15+++++++++++++--
2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/cmdfifo.c b/cmdfifo.c @@ -1,4 +1,5 @@ int cmdfd = -1; +unsigned short int client_id = 0; const char *cmdpath = NULL; /* glibc has a non-standard realpath(3) implementation which allocates diff --git a/dvtm.c b/dvtm.c @@ -41,6 +41,9 @@ struct Client { uint8_t order; pid_t pid; int pty; +#ifdef CONFIG_CMDFIFO + unsigned short int id; +#endif short int x; short int y; short int w; @@ -583,15 +586,23 @@ title_escape_seq_handler(madtty_t *term, char *es) { void create(const char *args[]) { + Client *c = calloc(sizeof(Client), 1); const char *cmd = (args && args[0]) ? args[0] : shell; const char *pargs[] = { "/bin/sh", "-c", cmd, NULL }; - Client *c = calloc(sizeof(Client), 1); +#ifdef CONFIG_CMDFIFO + c->id = ++client_id; + char buf[8]; + snprintf(buf, sizeof buf, "%d", c->id); + const char *env[] = { "DVTM_WINDOW_ID", buf, NULL }; +#else + const char *env[] = NULL; +#endif c->window = newwin(wah, waw, way, wax); c->term = madtty_create(height - 1, width); c->cmd = cmd; if (args && args[1]) strncpy(c->title, args[1], sizeof(c->title)); - c->pid = madtty_forkpty(c->term, "/bin/sh", pargs, &c->pty); + c->pid = madtty_forkpty(c->term, "/bin/sh", pargs, env, &c->pty); madtty_set_data(c->term, c); madtty_set_handler(c->term, title_escape_seq_handler); c->w = width;