Difference between revisions of "ProcessConnection"
From Fernseher
Jump to navigationJump to search
(New page: ProcessConnection is a class to represent an external process running on the server that is started by this script and runs independently. It can be read and written to as well. Start th...) |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
ProcessConnection is a class to represent an external process running on the server that is started by this script and runs independently. It can be read and written to as well. | ProcessConnection is a class to represent an external process running on the server that is started by this [[Modjs]] script and runs independently. It can be read and written to as well. | ||
Start the process by creating a new ProcessConnection: | Start the process by creating a new ProcessConnection: | ||
process = new ProcessConnection(cmd, args array) | process = new ProcessConnection(cmd, args array) | ||
process = new ProcessConnection(cmdandargs) | process = new ProcessConnection(cmdandargs) | ||
process = new ProcessConnection(File, args array) | |||
Read and write just like for TCPConnections: | Read and write just like for TCPConnections: | ||
Line 19: | Line 20: | ||
To send a signal to the process (and thus possibly killing it earlier, if needed): | To send a signal to the process (and thus possibly killing it earlier, if needed): | ||
process.signal(signum) | process.signal(signum) | ||
Exceptions can be thrown: | |||
ProcessConnectionOpenError | |||
ProcessConnectionChildClosed |
Latest revision as of 16:47, 21 January 2009
ProcessConnection is a class to represent an external process running on the server that is started by this Modjs script and runs independently. It can be read and written to as well.
Start the process by creating a new ProcessConnection:
process = new ProcessConnection(cmd, args array) process = new ProcessConnection(cmdandargs) process = new ProcessConnection(File, args array)
Read and write just like for TCPConnections:
process.send(string | array of strings) string = process.recvAll() string = process.recvLine(chomp?) array of strings = process.recvLines(numlines, chomp?) bool = process.dataAvailable()
Closing the process can be done by garbage collection or explicit close():
status = process.close()
Note that close() blocks until the process ends and a status is returned. Garbage collection will do the same.
To send a signal to the process (and thus possibly killing it earlier, if needed):
process.signal(signum)
Exceptions can be thrown:
ProcessConnectionOpenError ProcessConnectionChildClosed