Mercurial > vim
comparison src/os_win32.c @ 15539:ba876ced4f1f v8.1.0777
patch 8.1.0777: Win32: using pipes for channel does not work well
commit https://github.com/vim/vim/commit/b091f30bf38eacb31b9d8c97c82c7e0af9866301
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jan 19 14:37:00 2019 +0100
patch 8.1.0777: Win32: using pipes for channel does not work well
Problem: Win32: using pipes for channel does not work well.
Solution: Use a larger buffer and handle overlaps. (Yasuhiro Matsumoto,
closes #3782)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 19 Jan 2019 14:45:06 +0100 |
parents | 55ccc2d353bd |
children | dd725a8ab112 |
comparison
equal
deleted
inserted
replaced
15538:0ceb89cda5c2 | 15539:ba876ced4f1f |
---|---|
5426 } | 5426 } |
5427 } | 5427 } |
5428 # endif | 5428 # endif |
5429 } | 5429 } |
5430 | 5430 |
5431 /* | |
5432 * Create a pair of pipes. | |
5433 * Return TRUE for success, FALSE for failure. | |
5434 */ | |
5435 static BOOL | |
5436 create_pipe_pair(HANDLE handles[2]) | |
5437 { | |
5438 static LONG s; | |
5439 char name[64]; | |
5440 SECURITY_ATTRIBUTES sa; | |
5441 | |
5442 sprintf(name, "\\\\?\\pipe\\vim-%08lx-%08lx", | |
5443 GetCurrentProcessId(), | |
5444 InterlockedIncrement(&s)); | |
5445 | |
5446 // Create named pipe. Max size of named pipe is 65535. | |
5447 handles[1] = CreateNamedPipe( | |
5448 name, | |
5449 PIPE_ACCESS_OUTBOUND | FILE_FLAG_OVERLAPPED, | |
5450 PIPE_TYPE_BYTE | PIPE_NOWAIT, | |
5451 1, 65535, 0, 0, NULL); | |
5452 | |
5453 if (handles[1] == INVALID_HANDLE_VALUE) | |
5454 return FALSE; | |
5455 | |
5456 sa.nLength = sizeof(sa); | |
5457 sa.bInheritHandle = TRUE; | |
5458 sa.lpSecurityDescriptor = NULL; | |
5459 | |
5460 handles[0] = CreateFile(name, | |
5461 FILE_GENERIC_READ, | |
5462 FILE_SHARE_READ, &sa, | |
5463 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); | |
5464 | |
5465 if (handles[0] == INVALID_HANDLE_VALUE) | |
5466 { | |
5467 CloseHandle(handles[1]); | |
5468 return FALSE; | |
5469 } | |
5470 | |
5471 return TRUE; | |
5472 } | |
5473 | |
5431 void | 5474 void |
5432 mch_job_start(char *cmd, job_T *job, jobopt_T *options) | 5475 mch_job_start(char *cmd, job_T *job, jobopt_T *options) |
5433 { | 5476 { |
5434 STARTUPINFO si; | 5477 STARTUPINFO si; |
5435 PROCESS_INFORMATION pi; | 5478 PROCESS_INFORMATION pi; |
5491 { | 5534 { |
5492 semsg(_(e_notopen), fname); | 5535 semsg(_(e_notopen), fname); |
5493 goto failed; | 5536 goto failed; |
5494 } | 5537 } |
5495 } | 5538 } |
5496 else if (!use_null_for_in && | 5539 else if (!use_null_for_in |
5497 (!CreatePipe(&ifd[0], &ifd[1], &saAttr, 0) | 5540 && (!create_pipe_pair(ifd) |
5498 || !SetHandleInformation(ifd[1], HANDLE_FLAG_INHERIT, 0))) | 5541 || !SetHandleInformation(ifd[1], HANDLE_FLAG_INHERIT, 0))) |
5499 goto failed; | 5542 goto failed; |
5500 | 5543 |
5501 if (use_file_for_out) | 5544 if (use_file_for_out) |
5502 { | 5545 { |
5503 char_u *fname = options->jo_io_name[PART_OUT]; | 5546 char_u *fname = options->jo_io_name[PART_OUT]; |