summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/luasrc/sys.luadoc
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2018-11-12 10:48:08 +0100
committerJo-Philipp Wich <jo@mein.io>2018-11-14 20:46:04 +0100
commit6469b653544b0ed842a7af50cccb738baaceb4d9 (patch)
tree39f5ab590b6bc414c52d19e20b7bbb2d781565e6 /modules/luci-base/luasrc/sys.luadoc
parentcf3621522815544d42d1cc5cdf65b4fd1a6b4412 (diff)
luci-base: add luci.sys.process.exec()
The new process.exec() function simplifies spawning external processes and capturing their stdio. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/luasrc/sys.luadoc')
-rw-r--r--modules/luci-base/luasrc/sys.luadoc36
1 files changed, 36 insertions, 0 deletions
diff --git a/modules/luci-base/luasrc/sys.luadoc b/modules/luci-base/luasrc/sys.luadoc
index 3c7f69c6e9..162650e7ac 100644
--- a/modules/luci-base/luasrc/sys.luadoc
+++ b/modules/luci-base/luasrc/sys.luadoc
@@ -272,6 +272,42 @@ Send a signal to a process identified by given pid.
]]
---[[
+Execute a process, optionally capturing stdio.
+
+Executes the process specified by the given argv vector, e.g.
+`{ "/bin/sh", "-c", "echo 1" }` and waits for it to terminate unless a true
+value has been passed for the "nowait" parameter.
+
+When a function value is passed for the stdout or stderr arguments, the passed
+function is repeatedly called for each chunk read from the corresponding stdio
+stream. The read data is passed as string containing at most 4096 bytes at a
+time.
+
+When a true, non-function value is passed for the stdout or stderr arguments,
+the data of the corresponding stdio stream is read into an internal string
+buffer and returned as "stdout" or "stderr" field respectively in the result
+table.
+
+When a true value is passed to the nowait parameter, the function does not
+await process termination but returns as soon as all captured stdio streams
+have been closed or - if no streams are captured - immediately after launching
+the process.
+
+@class function
+@name process.exec
+@param commend Table containing the argv vector to execute
+@param stdout Callback function or boolean to indicate capturing (optional)
+@param stderr Callback function or boolean to indicate capturing (optional)
+@param nowait Don't wait for process termination when true (optional)
+@return Table containing at least the fields "code" which holds the exit
+ status of the invoked process or "-1" on error and "pid", which
+ contains the process id assigned to the spawned process. When
+ stdout and/or stderr capturing has been requested, it additionally
+ contains "stdout" and "stderr" fields respectively, holding the
+ captured stdio data as string.
+]]
+
+---[[
LuCI system utilities / user related functions.
@class module