summaryrefslogtreecommitdiffstats
path: root/runtime/doc/channel.txt
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-11-29 21:54:44 +0100
committerBram Moolenaar <Bram@vim.org>2016-11-29 21:54:44 +0100
commit4b785f69c0616dba5d3f38e8ce4b5398cec89407 (patch)
treefea8b654714ff391135ce61da9c9d0792b7a5265 /runtime/doc/channel.txt
parentf422bcc7f9615fe91fa69b059cfe4785093d3d4a (diff)
patch 8.0.0105v8.0.0105
Problem: When using ch_read() with zero timeout, can't tell the difference between reading an empty line and nothing available. Solution: Add ch_canread().
Diffstat (limited to 'runtime/doc/channel.txt')
-rw-r--r--runtime/doc/channel.txt11
1 files changed, 10 insertions, 1 deletions
diff --git a/runtime/doc/channel.txt b/runtime/doc/channel.txt
index 73105986f6..2c3f837300 100644
--- a/runtime/doc/channel.txt
+++ b/runtime/doc/channel.txt
@@ -418,7 +418,11 @@ This uses the channel timeout. To read without a timeout, just get any
message that is available: >
let output = ch_read(channel, {'timeout': 0})
When no message was available then the result is v:none for a JSON or JS mode
-channels, an empty string for a RAW or NL channel.
+channels, an empty string for a RAW or NL channel. You can use |ch_canread()|
+to check if there is something to read.
+
+Note that when there is no callback message are dropped. To avoid that add a
+close callback to the channel.
To read all output from a RAW channel that is available: >
let output = ch_readraw(channel)
@@ -470,6 +474,11 @@ This depends on the system (on Unix this happens because closing the write end
of a pipe causes the read end to get EOF). To avoid this make the job sleep
for a short while before it exits.
+Note that if the job exits before you read the output, the output may be lost.
+This depends on the system (on Unix this happens because closing the write end
+of a pipe causes the read end to get EOF). To avoid this make the job sleep
+for a short while before it exits.
+
The handler defined for "out_cb" will not receive stderr. If you want to
handle that separately, add an "err_cb" handler: >
let job = job_start(command, {"out_cb": "MyHandler",