diff options
| author | Omar Rizwan <omar@omar.website> | 2023-09-06 04:46:58 +0000 |
|---|---|---|
| committer | Omar Rizwan <omar@omar.website> | 2023-09-06 04:46:58 +0000 |
| commit | c6a1fcee99df646eadfd800e7ddb691f92733ca2 (patch) | |
| tree | eaa0caf323afbfec5fc5561e305544cf553bc26e /lib | |
| parent | terminal: lambda -> body (diff) | |
| download | folk-c6a1fcee99df646eadfd800e7ddb691f92733ca2.tar.gz folk-c6a1fcee99df646eadfd800e7ddb691f92733ca2.zip | |
terminal: slight hack to fix execvp
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/terminal.tcl | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/terminal.tcl b/lib/terminal.tcl index 04d054ff..16e553ca 100644 --- a/lib/terminal.tcl +++ b/lib/terminal.tcl @@ -38,7 +38,6 @@ namespace eval Terminal { } proc create {rows cols cmd} { - # End arguments with null string termCreate $rows $cols [list bash -c $cmd ""] } @@ -133,6 +132,13 @@ $cc code { } $cc proc termCreate {int rows int cols char* cmd[]} VTerminal* { + int i = 0; + while (true) { + // execvp requires cmd array to be terminated by null pointer + if (strlen(cmd[i]) == 0) { cmd[i] = NULL; break; } + i++; + } + VTerminal *vt = malloc(sizeof(VTerminal)); vt->curs_r = 0; vt->curs_c = 0; @@ -152,7 +158,9 @@ $cc proc termCreate {int rows int cols char* cmd[]} VTerminal* { return NULL; } else if (pid == 0){ setenv("TERM", "ansi", 1); - execvp(cmd[0], cmd); + if (execvp(cmd[0], cmd) == -1) { + fprintf(stderr, "execvp(%s, ...) failed: %m\n", cmd[0]); + } return NULL; } |
