Mercurial > vim
comparison src/os_unix.c @ 11898:3c1b59938042 v8.0.0829
patch 8.0.0829: job running in terminal can't communicate with Vim
commit https://github.com/vim/vim/commit/7da346035bf5837e6f5b734c5469477d981730f8
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Aug 1 17:14:21 2017 +0200
patch 8.0.0829: job running in terminal can't communicate with Vim
Problem: A job running in a terminal window cannot easily communicate with
the Vim it is running in.
Solution: Pass v:servername in an environment variable. (closes #1908)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 01 Aug 2017 17:15:04 +0200 |
parents | 75a85e99f53e |
children | 1e8d353cb827 |
comparison
equal
deleted
inserted
replaced
11897:ab52df5c8afc | 11898:3c1b59938042 |
---|---|
4092 return OK; | 4092 return OK; |
4093 } | 4093 } |
4094 #endif | 4094 #endif |
4095 | 4095 |
4096 #if !defined(USE_SYSTEM) || defined(FEAT_JOB_CHANNEL) | 4096 #if !defined(USE_SYSTEM) || defined(FEAT_JOB_CHANNEL) |
4097 /* | |
4098 * Set the environment for a child process. | |
4099 */ | |
4097 static void | 4100 static void |
4098 set_child_environment(long rows, long columns, char *term) | 4101 set_child_environment(long rows, long columns, char *term) |
4099 { | 4102 { |
4100 # ifdef HAVE_SETENV | 4103 # ifdef HAVE_SETENV |
4101 char envbuf[50]; | 4104 char envbuf[50]; |
4103 static char envbuf_Term[30]; | 4106 static char envbuf_Term[30]; |
4104 static char envbuf_Rows[20]; | 4107 static char envbuf_Rows[20]; |
4105 static char envbuf_Lines[20]; | 4108 static char envbuf_Lines[20]; |
4106 static char envbuf_Columns[20]; | 4109 static char envbuf_Columns[20]; |
4107 static char envbuf_Colors[20]; | 4110 static char envbuf_Colors[20]; |
4111 static char envbuf_Servername[60]; | |
4108 # endif | 4112 # endif |
4109 long colors = | 4113 long colors = |
4110 # ifdef FEAT_GUI | 4114 # ifdef FEAT_GUI |
4111 gui.in_use ? 256*256*256 : | 4115 gui.in_use ? 256*256*256 : |
4112 # endif | 4116 # endif |
4113 t_colors; | 4117 t_colors; |
4114 | 4118 |
4115 /* Simulate to have a dumb terminal (for now) */ | |
4116 # ifdef HAVE_SETENV | 4119 # ifdef HAVE_SETENV |
4117 setenv("TERM", term, 1); | 4120 setenv("TERM", term, 1); |
4118 sprintf((char *)envbuf, "%ld", rows); | 4121 sprintf((char *)envbuf, "%ld", rows); |
4119 setenv("ROWS", (char *)envbuf, 1); | 4122 setenv("ROWS", (char *)envbuf, 1); |
4120 sprintf((char *)envbuf, "%ld", rows); | 4123 sprintf((char *)envbuf, "%ld", rows); |
4121 setenv("LINES", (char *)envbuf, 1); | 4124 setenv("LINES", (char *)envbuf, 1); |
4122 sprintf((char *)envbuf, "%ld", columns); | 4125 sprintf((char *)envbuf, "%ld", columns); |
4123 setenv("COLUMNS", (char *)envbuf, 1); | 4126 setenv("COLUMNS", (char *)envbuf, 1); |
4124 sprintf((char *)envbuf, "%ld", colors); | 4127 sprintf((char *)envbuf, "%ld", colors); |
4125 setenv("COLORS", (char *)envbuf, 1); | 4128 setenv("COLORS", (char *)envbuf, 1); |
4129 setenv("VIM_SERVERNAME", serverName == NULL ? "" : (char *)serverName, 1); | |
4126 # else | 4130 # else |
4127 /* | 4131 /* |
4128 * Putenv does not copy the string, it has to remain valid. | 4132 * Putenv does not copy the string, it has to remain valid. |
4129 * Use a static array to avoid losing allocated memory. | 4133 * Use a static array to avoid losing allocated memory. |
4134 * This won't work well when running multiple children... | |
4130 */ | 4135 */ |
4131 vim_snprintf(envbuf_Term, sizeof(envbuf_Term), "TERM=%s", term); | 4136 vim_snprintf(envbuf_Term, sizeof(envbuf_Term), "TERM=%s", term); |
4132 putenv(envbuf_Term); | 4137 putenv(envbuf_Term); |
4133 vim_snprintf(envbuf_Rows, sizeof(envbuf_Rows), "ROWS=%ld", rows); | 4138 vim_snprintf(envbuf_Rows, sizeof(envbuf_Rows), "ROWS=%ld", rows); |
4134 putenv(envbuf_Rows); | 4139 putenv(envbuf_Rows); |
4137 vim_snprintf(envbuf_Columns, sizeof(envbuf_Columns), | 4142 vim_snprintf(envbuf_Columns, sizeof(envbuf_Columns), |
4138 "COLUMNS=%ld", columns); | 4143 "COLUMNS=%ld", columns); |
4139 putenv(envbuf_Columns); | 4144 putenv(envbuf_Columns); |
4140 vim_snprintf(envbuf_Colors, sizeof(envbuf_Colors), "COLORS=%ld", colors); | 4145 vim_snprintf(envbuf_Colors, sizeof(envbuf_Colors), "COLORS=%ld", colors); |
4141 putenv(envbuf_Colors); | 4146 putenv(envbuf_Colors); |
4147 vim_snprintf(envbuf_Servername, sizeof(envbuf_Servername), | |
4148 "VIM_SERVERNAME=%s", serverName == NULL ? "" : (char *)serverName); | |
4149 putenv(envbuf_Servername); | |
4142 # endif | 4150 # endif |
4143 } | 4151 } |
4144 | 4152 |
4145 static void | 4153 static void |
4146 set_default_child_environment(void) | 4154 set_default_child_environment(void) |