Mercurial > vim
comparison src/channel.c @ 12389:d0cf7f71b95b v8.0.1074
patch 8.0.1074: ":term NONE" does not work on MS-Windows
commit https://github.com/vim/vim/commit/2dc9d26c14e410c09e538cccfa90da19ae344ba4
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Sep 8 14:39:30 2017 +0200
patch 8.0.1074: ":term NONE" does not work on MS-Windows
Problem: ":term NONE" does not work on MS-Windows.
Solution: Make it work. Split "pty" into "pty_in" and "pty_out". (Yasuhiro
Matsumoto, closes #2058, closes #2045)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 08 Sep 2017 14:45:05 +0200 |
parents | 44f3c9b7eec4 |
children | 128cd982c7b8 |
comparison
equal
deleted
inserted
replaced
12388:9741eade42c9 | 12389:d0cf7f71b95b |
---|---|
967 /* When using a pty the same FD is set on multiple parts, only | 967 /* When using a pty the same FD is set on multiple parts, only |
968 * close it when the last reference is closed. */ | 968 * close it when the last reference is closed. */ |
969 if ((part == PART_IN || channel->CH_IN_FD != *fd) | 969 if ((part == PART_IN || channel->CH_IN_FD != *fd) |
970 && (part == PART_OUT || channel->CH_OUT_FD != *fd) | 970 && (part == PART_OUT || channel->CH_OUT_FD != *fd) |
971 && (part == PART_ERR || channel->CH_ERR_FD != *fd)) | 971 && (part == PART_ERR || channel->CH_ERR_FD != *fd)) |
972 { | |
973 #ifdef WIN32 | |
974 if (channel->ch_named_pipe) | |
975 DisconnectNamedPipe((HANDLE)fd); | |
976 #endif | |
972 fd_close(*fd); | 977 fd_close(*fd); |
978 } | |
973 } | 979 } |
974 *fd = INVALID_FD; | 980 *fd = INVALID_FD; |
975 | 981 |
976 channel->ch_to_be_closed &= ~(1 << part); | 982 channel->ch_to_be_closed &= ~(1 << part); |
977 } | 983 } |
3084 int r = PeekNamedPipe((HANDLE)fd, NULL, 0, NULL, &nread, NULL); | 3090 int r = PeekNamedPipe((HANDLE)fd, NULL, 0, NULL, &nread, NULL); |
3085 | 3091 |
3086 if (r && nread > 0) | 3092 if (r && nread > 0) |
3087 return CW_READY; | 3093 return CW_READY; |
3088 if (r == 0) | 3094 if (r == 0) |
3089 return CW_ERROR; | 3095 { |
3096 DWORD err = GetLastError(); | |
3097 | |
3098 if (err != ERROR_BAD_PIPE && err != ERROR_BROKEN_PIPE) | |
3099 return CW_ERROR; | |
3100 | |
3101 if (channel->ch_named_pipe) | |
3102 { | |
3103 DisconnectNamedPipe((HANDLE)fd); | |
3104 ConnectNamedPipe((HANDLE)fd, NULL); | |
3105 } | |
3106 else | |
3107 return CW_ERROR; | |
3108 } | |
3090 | 3109 |
3091 /* perhaps write some buffer lines */ | 3110 /* perhaps write some buffer lines */ |
3092 channel_write_any_lines(); | 3111 channel_write_any_lines(); |
3093 | 3112 |
3094 sleep_time = deadline - GetTickCount(); | 3113 sleep_time = deadline - GetTickCount(); |
3668 } | 3687 } |
3669 | 3688 |
3670 if (part == PART_SOCK) | 3689 if (part == PART_SOCK) |
3671 res = sock_write(fd, (char *)buf, len); | 3690 res = sock_write(fd, (char *)buf, len); |
3672 else | 3691 else |
3692 { | |
3673 res = fd_write(fd, (char *)buf, len); | 3693 res = fd_write(fd, (char *)buf, len); |
3694 #ifdef WIN32 | |
3695 if (channel->ch_named_pipe) | |
3696 { | |
3697 if (res < 0) | |
3698 { | |
3699 DisconnectNamedPipe((HANDLE)fd); | |
3700 ConnectNamedPipe((HANDLE)fd, NULL); | |
3701 } | |
3702 } | |
3703 #endif | |
3704 | |
3705 } | |
3674 if (res < 0 && (errno == EWOULDBLOCK | 3706 if (res < 0 && (errno == EWOULDBLOCK |
3675 #ifdef EAGAIN | 3707 #ifdef EAGAIN |
3676 || errno == EAGAIN | 3708 || errno == EAGAIN |
3677 #endif | 3709 #endif |
3678 )) | 3710 )) |
4847 job->jv_channel->ch_job = NULL; | 4879 job->jv_channel->ch_job = NULL; |
4848 channel_unref(job->jv_channel); | 4880 channel_unref(job->jv_channel); |
4849 } | 4881 } |
4850 mch_clear_job(job); | 4882 mch_clear_job(job); |
4851 | 4883 |
4852 vim_free(job->jv_tty_name); | 4884 vim_free(job->jv_tty_in); |
4885 vim_free(job->jv_tty_out); | |
4853 vim_free(job->jv_stoponexit); | 4886 vim_free(job->jv_stoponexit); |
4854 free_callback(job->jv_exit_cb, job->jv_exit_partial); | 4887 free_callback(job->jv_exit_cb, job->jv_exit_partial); |
4855 } | 4888 } |
4856 | 4889 |
4857 static void | 4890 static void |
5501 nr = job->jv_pid; | 5534 nr = job->jv_pid; |
5502 #else | 5535 #else |
5503 nr = job->jv_proc_info.dwProcessId; | 5536 nr = job->jv_proc_info.dwProcessId; |
5504 #endif | 5537 #endif |
5505 dict_add_nr_str(dict, "process", nr, NULL); | 5538 dict_add_nr_str(dict, "process", nr, NULL); |
5506 dict_add_nr_str(dict, "tty", 0L, | 5539 dict_add_nr_str(dict, "tty_in", 0L, |
5507 job->jv_tty_name != NULL ? job->jv_tty_name : (char_u *)""); | 5540 job->jv_tty_in != NULL ? job->jv_tty_in : (char_u *)""); |
5541 dict_add_nr_str(dict, "tty_out", 0L, | |
5542 job->jv_tty_out != NULL ? job->jv_tty_out : (char_u *)""); | |
5508 | 5543 |
5509 dict_add_nr_str(dict, "exitval", job->jv_exitval, NULL); | 5544 dict_add_nr_str(dict, "exitval", job->jv_exitval, NULL); |
5510 dict_add_nr_str(dict, "exit_cb", 0L, job->jv_exit_cb); | 5545 dict_add_nr_str(dict, "exit_cb", 0L, job->jv_exit_cb); |
5511 dict_add_nr_str(dict, "stoponexit", 0L, job->jv_stoponexit); | 5546 dict_add_nr_str(dict, "stoponexit", 0L, job->jv_stoponexit); |
5512 } | 5547 } |