Pass Go file descriptors and connections between different OS processes.

Siarhei Zirukin c6d800382f Merge pull request #1 from ibukanov/master 7 years ago
example f599800211 fix import paths 9 years ago
LICENSE.MIT 7d0013af48 first revision 10 years ago 7510a1459e readme: update 7 years ago
fd.go 1c220d4180 document that Get can return some files on errors 7 years ago
fd_test.go 7d0013af48 first revision 10 years ago


Package fd provides a simple API to pass file descriptors between different OS processes.

It can be useful if you want to inherit network connections from another process without closing them.

Example scenario:

  • Running server receives a "let's upgrade" message
  • Server opens a Unix domain socket for the "upgrade"
  • Server starts a new copy of itself and passes Unix domain socket name
  • New copy starts reading data from the socket
  • Server sends its state over the socket, also sending the number of network connections to inherit, then it sends those connections using fd.Put()
  • New server copy reads the state and inherits connections using fd.Get(), checks that everything is OK and writes an "OK" message to the socket
  • Server receives "OK" message and kills itself


fd on