diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-02-27 19:10:00 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-02-27 19:10:00 +0100 |
commit | 8195247054a659fe5cbc238197634d5e13e8e8e9 (patch) | |
tree | e1069ff3af65d73c58c694eaf552ff1e27cbbeef /src/testdir/test_channel.vim | |
parent | 988615f26f262d9ef6472c53b48868968a6b6d16 (diff) |
patch 8.0.1552: may leak file descriptors when executing jobv8.0.1552
Problem: May leak file descriptors when executing job.
Solution: Close more file descriptors. (Ozaki Kiichi, closes #2531)
Diffstat (limited to 'src/testdir/test_channel.vim')
-rw-r--r-- | src/testdir/test_channel.vim | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim index 1859afc5b8..9de3ca01f9 100644 --- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -23,6 +23,21 @@ func s:run_server(testfunc, ...) call RunServer('test_channel.py', a:testfunc, a:000) endfunc +" Return a list of open files. +" Can be used to make sure no resources leaked. +" Returns an empty list on systems where this is not supported. +func s:get_resources() + let pid = getpid() + + if has('mac') + return systemlist('lsof -p ' . pid . ' | awk ''$4~/^[0-9]*[rwu]$/&&$5=="REG"{print$NF}''') + elseif isdirectory('/proc/' . pid . '/fd/') + return systemlist('readlink /proc/' . pid . '/fd/* | grep -v ''^/dev/''') + else + return [] + endif +endfunc + let g:Ch_responseMsg = '' func Ch_requestHandler(handle, msg) let g:Ch_responseHandle = a:handle @@ -620,6 +635,7 @@ func Test_nl_write_out_file() call assert_equal(['line one', 'line two', 'this', 'AND this'], readfile('Xoutput')) finally call Stop_g_job() + call assert_equal(-1, match(s:get_resources(), '\(^\|/\)Xoutput$')) call delete('Xoutput') endtry endfunc @@ -663,6 +679,7 @@ func Test_nl_write_both_file() call assert_equal(['line one', 'line two', 'this', 'AND this', 'that', 'AND that'], readfile('Xoutput')) finally call Stop_g_job() + call assert_equal(-1, match(s:get_resources(), '\(^\|/\)Xoutput$')) call delete('Xoutput') endtry endfunc @@ -1662,6 +1679,7 @@ func Test_raw_passes_nul() call assert_equal("asdf\nasdf", getline(1)) call assert_equal("xxx\n", getline(2)) call assert_equal("\nyyy", getline(3)) + call assert_equal(-1, match(s:get_resources(), '\(^\|/\)Xtestwrite$')) call delete('Xtestwrite') bwipe! |