Skip to content

Commit 1ad7413

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 2dca511 + c8dcbb1 commit 1ad7413

File tree

17 files changed

+108
-43
lines changed

17 files changed

+108
-43
lines changed

Filelist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ SRC_ALL = \
66
.hgignore \
77
.travis.yml \
88
appveyor.yml \
9+
src/appveyor.bat \
910
src/README.txt \
1011
src/alloc.h \
1112
src/arabic.c \

runtime/doc/eval.txt

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4474,21 +4474,27 @@ job_status({job}) *job_status()* *E916*
44744474
job_stop({job} [, {how}]) *job_stop()*
44754475
Stop the {job}. This can also be used to signal the job.
44764476

4477-
When {how} is omitted or is "term" the job will be terminated
4478-
normally. For Unix SIGTERM is sent. For MS-Windows
4479-
CTRL_BREAK will be sent. This goes to the process group, thus
4480-
children may also be affected.
4481-
4482-
Other values for Unix:
4483-
"hup" Unix: SIGHUP
4484-
"quit" Unix: SIGQUIT
4485-
"kill" Unix: SIGKILL (strongest way to stop)
4486-
number Unix: signal with that number
4487-
4488-
Other values for MS-Windows:
4489-
"int" Windows: CTRL_C
4490-
"kill" Windows: terminate process forcedly
4491-
Others Windows: CTRL_BREAK
4477+
When {how} is omitted or is "term" the job will be terminated.
4478+
For Unix SIGTERM is sent. On MS-Windows the job will be
4479+
terminated forcedly (there is no "gentle" way).
4480+
This goes to the process group, thus children may also be
4481+
affected.
4482+
4483+
Effect for Unix:
4484+
"term" SIGTERM (default)
4485+
"hup" SIGHUP
4486+
"quit" SIGQUIT
4487+
"int" SIGINT
4488+
"kill" SIGKILL (strongest way to stop)
4489+
number signal with that number
4490+
4491+
Effect for MS-Windows:
4492+
"term" terminate process forcedly (default)
4493+
"hup" CTRL_BREAK
4494+
"quit" CTRL_BREAK
4495+
"int" CTRL_C
4496+
"kill" terminate process forcedly
4497+
Others CTRL_BREAK
44924498

44934499
On Unix the signal is sent to the process group. This means
44944500
that when the job is "sh -c command" it affects both the shell

runtime/doc/starting.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,10 @@ a slash. Thus "-R" means recovery and "-/R" readonly.
414414
not needed, because Vim will be able to find out what type
415415
of terminal you are using. (See |terminal-info|.) {not in Vi}
416416

417+
--not-a-term Tells Vim that the user knows that the input and/or output is
418+
not connected to a terminal. This will avoid the warning and
419+
the two second delay that would happen.
420+
417421
*-d*
418422
-d Start in diff mode, like |vimdiff|.
419423
{not in Vi} {not available when compiled without the |+diff|

src/channel.c

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,31 @@ add_channel(void)
309309
return channel;
310310
}
311311

312+
/*
313+
* Return TRUE if "channel" has a callback.
314+
*/
315+
static int
316+
channel_has_callback(channel_T *channel)
317+
{
318+
return channel->ch_callback != NULL
319+
#ifdef CHANNEL_PIPES
320+
|| channel->ch_part[PART_OUT].ch_callback != NULL
321+
|| channel->ch_part[PART_ERR].ch_callback != NULL
322+
#endif
323+
|| channel->ch_close_cb != NULL;
324+
}
325+
326+
/*
327+
* Close a channel and free all its resources if there is no further action
328+
* possible, there is no callback to be invoked.
329+
*/
330+
void
331+
channel_may_free(channel_T *channel)
332+
{
333+
if (!channel_has_callback(channel))
334+
channel_free(channel);
335+
}
336+
312337
/*
313338
* Close a channel and free all its resources.
314339
*/
@@ -1482,7 +1507,7 @@ channel_status(channel_T *channel)
14821507

14831508
/*
14841509
* Close channel "channel".
1485-
* This does not trigger the close callback.
1510+
* Trigger the close callback if "invoke_close_cb" is TRUE.
14861511
*/
14871512
void
14881513
channel_close(channel_T *channel, int invoke_close_cb)
@@ -2168,6 +2193,14 @@ channel_parse_messages(void)
21682193

21692194
while (channel != NULL)
21702195
{
2196+
if (channel->ch_refcount == 0 && !channel_has_callback(channel))
2197+
{
2198+
/* channel is no longer useful, free it */
2199+
channel_free(channel);
2200+
channel = first_channel;
2201+
part = PART_SOCK;
2202+
continue;
2203+
}
21712204
if (channel->ch_part[part].ch_fd != INVALID_FD)
21722205
{
21732206
/* Increase the refcount, in case the handler causes the channel

src/eval.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7745,16 +7745,16 @@ get_dict_tv(char_u **arg, typval_T *rettv, int evaluate)
77457745

77467746
#if defined(FEAT_CHANNEL) || defined(PROTO)
77477747
/*
7748-
* Decrement the reference count on "channel" and free it when it goes down to
7749-
* zero.
7748+
* Decrement the reference count on "channel" and maybe free it when it goes
7749+
* down to zero. Don't free it if there is a pending action.
77507750
* Returns TRUE when the channel was freed.
77517751
*/
77527752
int
77537753
channel_unref(channel_T *channel)
77547754
{
77557755
if (channel != NULL && --channel->ch_refcount <= 0)
77567756
{
7757-
channel_free(channel);
7757+
channel_may_free(channel);
77587758
return TRUE;
77597759
}
77607760
return FALSE;

src/integration.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ widgetIsIconified(
805805
if (XtWindow(w) != 0) { /* only check if window exists! */
806806
XGetWindowProperty(XtDisplay(w), XtWindow(w), wm_state, 0L, 2L,
807807
False, AnyPropertyType, &act_type, &act_fmt, &nitems_ret,
808-
&bytes_after, (u_char **) &property);
808+
&bytes_after, (char_u **) &property);
809809
if (nitems_ret == 2 && property[0] == IconicState) {
810810
return True;
811811
}

src/macros.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
#endif
120120

121121
/* Returns empty string if it is NULL. */
122-
#define EMPTY_IF_NULL(x) ((x) ? (x) : (u_char *)"")
122+
#define EMPTY_IF_NULL(x) ((x) ? (x) : (char_u *)"")
123123

124124
#ifdef FEAT_LANGMAP
125125
/*

src/main.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ typedef struct
5050

5151
int want_full_screen;
5252
int stdout_isatty; /* is stdout a terminal? */
53+
int not_a_term; /* no warning for missing term? */
5354
char_u *term; /* specified terminal name */
5455
#ifdef FEAT_CRYPT
5556
int ask_for_key; /* -x argument */
@@ -1929,6 +1930,7 @@ command_line_scan(mparm_T *parmp)
19291930
/* "--version" give version message */
19301931
/* "--literal" take files literally */
19311932
/* "--nofork" don't fork */
1933+
/* "--not-a-term" don't warn for not a term */
19321934
/* "--noplugin[s]" skip plugins */
19331935
/* "--cmd <cmd>" execute cmd before vimrc */
19341936
if (STRICMP(argv[0] + argv_idx, "help") == 0)
@@ -1956,6 +1958,8 @@ command_line_scan(mparm_T *parmp)
19561958
}
19571959
else if (STRNICMP(argv[0] + argv_idx, "noplugin", 8) == 0)
19581960
p_lpl = FALSE;
1961+
else if (STRNICMP(argv[0] + argv_idx, "not-a-term", 10) == 0)
1962+
parmp->not_a_term = TRUE;
19591963
else if (STRNICMP(argv[0] + argv_idx, "cmd", 3) == 0)
19601964
{
19611965
want_argument = TRUE;
@@ -2598,7 +2602,7 @@ check_tty(mparm_T *parmp)
25982602
/* don't want the delay when started from the desktop */
25992603
&& !gui.starting
26002604
#endif
2601-
)
2605+
&& !parmp->not_a_term)
26022606
{
26032607
#ifdef NBDEBUG
26042608
/*
@@ -3382,6 +3386,7 @@ usage(void)
33823386
main_msg(_("-F\t\t\tStart in Farsi mode"));
33833387
#endif
33843388
main_msg(_("-T <terminal>\tSet terminal type to <terminal>"));
3389+
main_msg(_("--not-a-term\t\tSkip warning for input/output not being a terminal"));
33853390
main_msg(_("-u <vimrc>\t\tUse <vimrc> instead of any .vimrc"));
33863391
#ifdef FEAT_GUI
33873392
main_msg(_("-U <gvimrc>\t\tUse <gvimrc> instead of any .gvimrc"));

src/os_unix.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5224,12 +5224,14 @@ mch_stop_job(job_T *job, char_u *how)
52245224
int sig = -1;
52255225
pid_t job_pid;
52265226

5227-
if (STRCMP(how, "hup") == 0)
5228-
sig = SIGHUP;
5229-
else if (*how == NUL || STRCMP(how, "term") == 0)
5227+
if (*how == NUL || STRCMP(how, "term") == 0)
52305228
sig = SIGTERM;
5229+
else if (STRCMP(how, "hup") == 0)
5230+
sig = SIGHUP;
52315231
else if (STRCMP(how, "quit") == 0)
52325232
sig = SIGQUIT;
5233+
else if (STRCMP(how, "int") == 0)
5234+
sig = SIGINT;
52335235
else if (STRCMP(how, "kill") == 0)
52345236
sig = SIGKILL;
52355237
else if (isdigit(*how))

src/os_win32.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5141,10 +5141,9 @@ mch_job_status(job_T *job)
51415141
int
51425142
mch_stop_job(job_T *job, char_u *how)
51435143
{
5144-
int ret = 0;
5145-
int ctrl_c = STRCMP(how, "int") == 0;
5144+
int ret;
51465145

5147-
if (STRCMP(how, "kill") == 0)
5146+
if (STRCMP(how, "term") == 0 || STRCMP(how, "kill") == 0 || *how == NUL)
51485147
{
51495148
if (job->jv_job_object != NULL)
51505149
return TerminateJobObject(job->jv_job_object, 0) ? OK : FAIL;
@@ -5155,9 +5154,9 @@ mch_stop_job(job_T *job, char_u *how)
51555154
if (!AttachConsole(job->jv_proc_info.dwProcessId))
51565155
return FAIL;
51575156
ret = GenerateConsoleCtrlEvent(
5158-
ctrl_c ? CTRL_C_EVENT : CTRL_BREAK_EVENT,
5159-
job->jv_proc_info.dwProcessId)
5160-
? OK : FAIL;
5157+
STRCMP(how, "int") == 0 ? CTRL_C_EVENT : CTRL_BREAK_EVENT,
5158+
job->jv_proc_info.dwProcessId)
5159+
? OK : FAIL;
51615160
FreeConsole();
51625161
return ret;
51635162
}

0 commit comments

Comments
 (0)