Patch 7.4.1532
Problem: MS-Windows channel leaks file descriptor.
Solution: Use CreateFile with the right options. (Yasuhiro Matsumoto)
Files: src/os_win32.c
*** ../vim-7.4.1531/src/os_win32.c 2016-03-10 16:33:25.805653271 +0100
--- src/os_win32.c 2016-03-10 21:41:27.389055348 +0100
***************
*** 4992,4997 ****
--- 4992,5032 ----
}
#if defined(FEAT_JOB) || defined(PROTO)
+ static HANDLE
+ job_io_file_open(
+ char_u *fname,
+ DWORD dwDesiredAccess,
+ DWORD dwShareMode,
+ LPSECURITY_ATTRIBUTES lpSecurityAttributes,
+ DWORD dwCreationDisposition,
+ DWORD dwFlagsAndAttributes)
+ {
+ HANDLE h;
+ # ifdef FEAT_MBYTE
+ WCHAR *wn = NULL;
+ if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
+ {
+ wn = enc_to_utf16(fname, NULL);
+ if (wn != NULL)
+ {
+ h = CreateFileW(wn, dwDesiredAccess, dwShareMode,
+ lpSecurityAttributes, dwCreationDisposition,
+ dwFlagsAndAttributes, NULL);
+ vim_free(wn);
+ if (h == INVALID_HANDLE_VALUE
+ && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
+ wn = NULL;
+ }
+ }
+ if (wn == NULL)
+ # endif
+
+ h = CreateFile((LPCSTR)fname, dwDesiredAccess, dwShareMode,
+ lpSecurityAttributes, dwCreationDisposition,
+ dwFlagsAndAttributes, NULL);
+ return h;
+ }
+
void
mch_start_job(char *cmd, job_T *job, jobopt_T *options)
{
***************
*** 5046,5058 ****
{
char_u *fname = options->jo_io_name[PART_IN];
! int fd = mch_open((char *)fname, O_RDONLY, 0);
! if (fd < 0)
{
EMSG2(_(e_notopen), fname);
goto failed;
}
- ifd[0] = (HANDLE)_get_osfhandle(fd);
}
else if (!use_null_for_in &&
(!CreatePipe(&ifd[0], &ifd[1], &saAttr, 0)
--- 5081,5094 ----
{
char_u *fname = options->jo_io_name[PART_IN];
! ifd[0] = job_io_file_open(fname, GENERIC_READ,
! FILE_SHARE_READ | FILE_SHARE_WRITE,
! &saAttr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL);
! if (ifd[0] == INVALID_HANDLE_VALUE)
{
EMSG2(_(e_notopen), fname);
goto failed;
}
}
else if (!use_null_for_in &&
(!CreatePipe(&ifd[0], &ifd[1], &saAttr, 0)
***************
*** 5063,5075 ****
{
char_u *fname = options->jo_io_name[PART_OUT];
! int fd = mch_open((char *)fname, O_WRONLY | O_CREAT | O_TRUNC, 0644);
! if (fd < 0)
{
EMSG2(_(e_notopen), fname);
goto failed;
}
- ofd[1] = (HANDLE)_get_osfhandle(fd);
}
else if (!use_null_for_out &&
(!CreatePipe(&ofd[0], &ofd[1], &saAttr, 0)
--- 5099,5112 ----
{
char_u *fname = options->jo_io_name[PART_OUT];
! ofd[1] = job_io_file_open(fname, GENERIC_WRITE,
! FILE_SHARE_READ | FILE_SHARE_WRITE,
! &saAttr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL);
! if (ofd[1] == INVALID_HANDLE_VALUE)
{
EMSG2(_(e_notopen), fname);
goto failed;
}
}
else if (!use_null_for_out &&
(!CreatePipe(&ofd[0], &ofd[1], &saAttr, 0)
***************
*** 5080,5092 ****
{
char_u *fname = options->jo_io_name[PART_ERR];
! int fd = mch_open((char *)fname, O_WRONLY | O_CREAT | O_TRUNC, 0600);
! if (fd < 0)
{
EMSG2(_(e_notopen), fname);
goto failed;
}
- efd[1] = (HANDLE)_get_osfhandle(fd);
}
else if (!use_out_for_err && !use_null_for_err &&
(!CreatePipe(&efd[0], &efd[1], &saAttr, 0)
--- 5117,5130 ----
{
char_u *fname = options->jo_io_name[PART_ERR];
! efd[1] = job_io_file_open(fname, GENERIC_WRITE,
! FILE_SHARE_READ | FILE_SHARE_WRITE,
! &saAttr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL);
! if (efd[1] == INVALID_HANDLE_VALUE)
{
EMSG2(_(e_notopen), fname);
goto failed;
}
}
else if (!use_out_for_err && !use_null_for_err &&
(!CreatePipe(&efd[0], &efd[1], &saAttr, 0)
*** ../vim-7.4.1531/src/version.c 2016-03-10 21:10:54.452368808 +0100
--- src/version.c 2016-03-10 21:42:22.724473204 +0100
***************
*** 745,746 ****
--- 745,748 ----
{ /* Add new patch number below this line */
+ /**/
+ 1532,
/**/
--
Far out in the uncharted backwaters of the unfashionable end of the
Western Spiral arm of the Galaxy lies a small unregarded yellow sun.
Orbiting this at a distance of roughly ninety-eight million miles is an
utterly insignificant little blue-green planet whose ape-descended life
forms are so amazingly primitive that they still think digital watches
are a pretty neat idea ...
-- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.