[systemd-devel] How to control socket activation when it run respawn infinitely.

David Timothy Strauss david at davidstrauss.net
Mon Dec 30 14:59:56 PST 2013


On Mon, Dec 30, 2013 at 7:59 AM, Tony Seo <tonyseo7 at gmail.com> wrote:
> That situation continued whether "Accept= true" or not in service unit.

The reason I encouraged you to learn more about socket programming is
because this Accept= option isn't some sort of optimization or nuanced
thing you just try either way until you get it working. What layer
handles accept() for connection-oriented protocols (systemd versus a
daemon) is a fundamental aspect of socket programming. If you don't
understand what Accept=true and Accept=false are supposed to do and
just go about trying both, you still have more learning to do.

Specifically, Accept=true means systemd handles the accept() calls and
spawns an instance of the service for each connection. The socket
passed into the service is one corresponding to a single client's
connection. It is therefore appropriate to simply read from and write
to fd=3. Trying to accept() from fd=3 will probably block forever if
it works at all.

Accept=false (the default) means systemd merely handles the listener
socket. The service must make its own accept() calls to get sockets
corresponding to individual client connections. The service should not
directly read from and write from fd=3; it should do that with the
socket instantiated by accept().


More information about the systemd-devel mailing list