dvtm

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

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

Add a parameter to madtty_forkpty to specify additional environment variables

The new const char *env[] parameter should contain the name of the
environment variable and it's value in the next element. The array must
be terminated with a NULL pointer.

const char *env[] = { "NAME1", "VALUE1", "NAME2", "VALUE2", NULL };

Diffstat:
madtty.c | 7++++++-
madtty.h | 2+-
2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/madtty.c b/madtty.c @@ -1013,10 +1013,11 @@ void madtty_draw(madtty_t *t, WINDOW *win, int srow, int scol) /******************************************************/ -pid_t madtty_forkpty(madtty_t *t, const char *p, const char *argv[], int *pty) +pid_t madtty_forkpty(madtty_t *t, const char *p, const char *argv[], const char *env[], int *pty) { struct winsize ws; pid_t pid; + const char **envp = env; ws.ws_row = t->rows; ws.ws_col = t->cols; @@ -1028,6 +1029,10 @@ pid_t madtty_forkpty(madtty_t *t, const char *p, const char *argv[], int *pty) if (pid == 0) { setsid(); + while (envp && envp[0]) { + setenv(envp[0], envp[1], 1); + envp += 2; + } setenv("TERM", "rxvt", 1); execv(p, (char *const*)argv); fprintf(stderr, "\nexecv() failed.\nCommand: '%s'\n", argv[0]); diff --git a/madtty.h b/madtty.h @@ -62,7 +62,7 @@ int madtty_color_pair(int fg, int bg); madtty_t *madtty_create(int rows, int cols); void madtty_resize(madtty_t *, int rows, int cols); void madtty_destroy(madtty_t *); -pid_t madtty_forkpty(madtty_t *, const char *, const char *argv[], int *pty); +pid_t madtty_forkpty(madtty_t *, const char *, const char *argv[], const char *envp[], int *pty); int madtty_getpty(madtty_t *); unsigned madtty_cursor(madtty_t *t);