mirror of
https://github.com/tsl0922/ttyd.git
synced 2025-12-25 13:14:18 +01:00
pty: set TERM env for the pty process
This commit is contained in:
@@ -110,6 +110,7 @@ static bool spawn_process(struct pss_tty *pss, uint16_t columns, uint16_t rows)
|
||||
pty_process *process = process_init((void *) pss, server->loop, argv);
|
||||
if (columns > 0) process->columns = columns;
|
||||
if (rows > 0) process->rows = rows;
|
||||
strncpy(process->term, server->terminal_type, sizeof(process->term));
|
||||
if (pty_spawn(process, process_read_cb, process_exit_cb) != 0) {
|
||||
lwsl_err("pty_spawn: %d (%s)\n", errno, strerror(errno));
|
||||
process_free(process);
|
||||
|
||||
@@ -334,6 +334,11 @@ int pty_spawn(pty_process *process, pty_read_cb read_cb, pty_exit_cb exit_cb) {
|
||||
cmdline = join_args(process->argv);
|
||||
if (cmdline == NULL) goto cleanup;
|
||||
|
||||
// TODO: restore env after process creation
|
||||
if (!SetEnvironmentVariable("TERM", process->term)) {
|
||||
print_error("SetEnvironmentVariable");
|
||||
}
|
||||
|
||||
if (!CreateProcessW(NULL, cmdline, NULL, NULL, FALSE, flags, NULL, NULL, &process->si.StartupInfo, &pi)) {
|
||||
print_error("CreateProcessW");
|
||||
goto cleanup;
|
||||
@@ -421,6 +426,7 @@ int pty_spawn(pty_process *process, pty_read_cb read_cb, pty_exit_cb exit_cb) {
|
||||
return status;
|
||||
} else if (pid == 0) {
|
||||
setsid();
|
||||
setenv("TERM", process->term, true);
|
||||
int ret = execvp(process->argv[0], process->argv);
|
||||
if (ret < 0) {
|
||||
perror("execvp failed\n");
|
||||
|
||||
Reference in New Issue
Block a user