Summary

In this chapter, we learned how to handle communications between processes using three main functionalities: exit codes, signals, and pipes.

Exit codes are 8-bit values between 0 and 255 that are returned by a process to their parent. An exit code of 0 means that the application execution was successful. It's pretty easy to return an exit code in Go, but doing so using the os.Exit function shortcuts the execution of the deferred functions. When a panic occurs, all the deferred functions are executed and the returned code is 2. Getting an exit code from a child process is relatively trickier, because it's OS-dependent; however, in Unix systems, it can be accomplished using a series of type assertions.

Signals are used to communicate with any process. They are 6-bit values, between 1 and 64, sent from one process to another using a system call. Receiving signals can be done using a channel and the signal.Notify function. Sending signals is easily done with the Process.Signal method.

Pipes are a tuple of input and output streams that are synchronously connected. They are used to connect a process input to another process output. We saw how to connect multiple commands in the same way that a Terminal does and we learned how to use io.MultiReader to broadcast one command output to many commands.

In the next chapter, we are going to dig into network programming, starting from TCP all the way up to HTTP servers.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.135.80