On this page
hs.task
Execute processes in the background and capture their output
Notes:
- This is not intended to be used for processes which never exit. While it is possible to run such things with hs.task, it is not possible to read their output while they run and if they produce significant output, eventually the internal OS buffers will fill up and the task will be suspended.
- An hs.task object can only be used once
API Overview
- Functions - API calls offered directly by the extension
- Methods - API calls which can only be made on an object returned by a constructor
API Documentation
Functions
new
Signature | hs.task.new(launchPath, callbackFn[, streamCallbackFn][, arguments]) -> hs.task object |
---|---|
Type | Function |
Description | Creates a new hs.task object |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/task/libtask.m line 176 |
Methods
closeInput
Signature | hs.task:closeInput() -> hs.task object |
---|---|
Type | Method |
Description | Closes the task's stdin |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/task/libtask.m line 323 |
environment
Signature | hs.task:environment() -> environment |
---|---|
Type | Method |
Description | Returns the environment variables as a table for the task. |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/task/libtask.m line 745 |
interrupt
Signature | hs.task:interrupt() -> hs.task object |
---|---|
Type | Method |
Description | Interrupts the task |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/task/libtask.m line 535 |
isRunning
Signature | hs.task:isRunning() -> boolean |
---|---|
Type | Method |
Description | Test if a task is still running. |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/task/libtask.m line 683 |
pause
Signature | hs.task:pause() -> boolean |
---|---|
Type | Method |
Description | Pauses the task |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/task/libtask.m line 563 |
pid
Signature | hs.task:pid() -> integer |
---|---|
Type | Method |
Description | Gets the PID of a running/finished task |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/task/libtask.m line 433 |
resume
Signature | hs.task:resume() -> boolean |
---|---|
Type | Method |
Description | Resumes the task |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/task/libtask.m line 596 |
setCallback
Signature | hs.task:setCallback(fn) -> hs.task object |
---|---|
Type | Method |
Description | Set or remove a callback function for a task. |
Parameters |
|
Returns |
|
Source | extensions/task/libtask.m line 254 |
setEnvironment
Signature | hs.task:setEnvironment(environment) -> hs.task object | false |
---|---|
Type | Method |
Description | Sets the environment variables for the task. |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/task/libtask.m line 770 |
setInput
Signature | hs.task:setInput(inputData) -> hs.task object |
---|---|
Type | Method |
Description | Sets the standard input data for a task |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/task/libtask.m line 278 |
setStreamingCallback
Signature | hs.task:setStreamingCallback(fn) -> hs.task object |
---|---|
Type | Method |
Description | Set a stream callback function for a task |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/task/libtask.m line 351 |
setWorkingDirectory
Signature | hs.task:setWorkingDirectory(path) -> hs.task object | false |
---|---|
Type | Method |
Description | Sets the working directory for the task. |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/task/libtask.m line 401 |
start
Signature | hs.task:start() -> hs.task object | false |
---|---|
Type | Method |
Description | Starts the task |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/task/libtask.m line 454 |
terminate
Signature | hs.task:terminate() -> hs.task object |
---|---|
Type | Method |
Description | Terminates the task |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/task/libtask.m line 507 |
terminationReason
Signature | hs.task:terminationReason() -> exitCode | false |
---|---|
Type | Method |
Description | Returns the termination reason for a task, or false if the task is still running. |
Parameters |
|
Returns |
|
Source | extensions/task/libtask.m line 710 |
terminationStatus
Signature | hs.task:terminationStatus() -> exitCode | false |
---|---|
Type | Method |
Description | Returns the termination status of a task, or false if the task is still running. |
Parameters |
|
Returns |
|
Source | extensions/task/libtask.m line 652 |
waitUntilExit
Signature | hs.task:waitUntilExit() -> hs.task object |
---|---|
Type | Method |
Description | Blocks Hammerspoon until the task exits |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/task/libtask.m line 628 |
workingDirectory
Signature | hs.task:workingDirectory() -> path |
---|---|
Type | Method |
Description | Returns the working directory for the task. |
Parameters |
|
Returns |
|
Notes |
|
Source | extensions/task/libtask.m line 379 |
© 2014–2017 Hammerspoon contributors
Licensed under the MIT License.
https://www.hammerspoon.org/docs/hs.task.html