[systemd-devel] how to end a socket activated daemon
Lennart Poettering
lennart at poettering.net
Mon Jun 17 11:51:51 PDT 2013
On Fri, 14.06.13 14:33, Zbigniew Jędrzejewski-Szmek (zbyszek at in.waw.pl) wrote:
> On Fri, Jun 14, 2013 at 10:03:00AM +0200, Łukasz Stelmach wrote:
> > Hi.
> >
> > We are converting some daemons to socket activation. Most of them open
> > unix sockets and manage incoming connections in a main-loop, so the
> > easiest way to convert it is to create Accept=false socket with systemd.
> >
> > Now, it is quite well described how to start such daemon, however, there
> > is little about shutting it down. Should the daemon close(2) the
> > received sockets? Should it unlink(2) them from a filesystem?
> close() yes, unlink() no.
Strictly speaking you don't even have to do that. The kernel will clean
up left-over fds when your process exits, hence you don't have to close
it explicitly.
But you certainly should not unlink() the socket in the fs, because then
the socket will not be accessible anymore.
Lennart
--
Lennart Poettering - Red Hat, Inc.
More information about the systemd-devel
mailing list