Client Master Command
1 ----------> | Command, Arguments, Pid
2 ----------> | Terminal IO
3 -----------> | Terminal IO
4 -----------> | Arguments, Pid
5 <----------- | pid
6 <--------- | pid
(time passes)
7 <----------- | exit status
8 <--------- | exit status
The Master always has a UNIX domain server listening at a known socket path.
The Client connects to this server and sends a string indicating the command to run and any arguments to run with (ie. the ARGV). See message_format.md for more info.
The Client then sends an IO over the server socket to be used for raw terminal IO.
The Master sends the Client arguments from step 1 to the Command.
The Master forks a new Command process and sends it the Terminal IO from the Client.
The Command process sends the Master its pid, using a Pid & Identifier message.
The Master responds to the client with the pid of the newly-forked Command process.
The Client is now connected to the Command process.
When the command terminates, it must send its exit code to the master. This is normally easiest to implement as a wrapper process that does the setsid, then forks the command and waitpid
s on it.
The form of this message is {{code}}
, eg: 1
.
Finally, the Master forwards the exit status to the Client. The command cycle is now complete.
The form of this message is {{code}}
, eg: 1
.
See message_format.md
for more information on messages.