No title

Anonymous Coward 2018-03-06 17:55:34.113596 UTC

Listen, listen1, savelog: supervise a service.

	listen -a address [-u user] [-g group] [-l logfile] [-svc name] cmd [args...]
	listen1 -a address [-u user] [-g group] [-l logfile] [-svc name] cmd [args...]

Listen announces address on the local network and prepares a socket
for accepting connections. It then starts cmd with the specified
arguments, assigning fd=0 to the created socket, while also dropping
privileges to user:group (default nobody:nobody). Cmd must call
accept(2) in a loop on fd=0.

Listen also opens logfile for appending, then starts savelog, running
as nobody:nobody. Fd=2 in cmd is connected to fd=0 in savelog via
a pipe, while fd=1 in savelog is the opened log file. Fd=2 in savelog
is cmd's fd=2.

Listen sets argv0 in the cmd process to name, and to name.log in
the savelog process. If name is not specified it defaults to cmd's
base name.

Listen will restart processes if necessary. It is okay to kill the
savelog process in order to rotate log files.

Listen passes SIGHUP to the cmd process and will kill the savelog
process on SIGUSR1.

Listen1 is like listen, except that it will also do the accept
service loop, passing the accepted file descriptor as fd=0, and
fd=1 to cmd. Cmd must then read(1) from fd=0 and write(2) to fd=1.
In this model there is one cmd process per connection, but savelog
is still long-lived.