init: Add option to listen on sockets before starting service.

Review note: Original change was a p-o-c by agl in
https://r.android.com/2094350 which I think is actually
production quality.  I'm just taking it over so that he doesn't
get spammed by any review comments as that's not a good use
of his time.

Needed for the hardware entropy daemon (see bug).

Original commit message:
If one needs to create a service that synchronously starts listening on
a socket then there are currently no good options.

The traditional UNIX solution is to have the service create the socket
and then daemonise. In this situation, init could start the service with
`exec_start` and yet not block forever because the service forks and
exits. However, when the initial child process exits, init kills the
daemon process:

> init: Killed 1 additional processes from a oneshot process group for
> service 'foo'. This is new behavior, previously child processes
> would not be killed in this case.

Next, there is a `socket` option for services and (although the
documentation didn't nail this down), the socket is created
synchronously by `start`. However, init doesn't call `listen` on the
socket so, until the service starts listening on the socket itself,
clients will get ECONNREFUSED.

This this change adds a `+listen` option, similar to `+passcred` which
allows a socket service to reliably handle connections.

Bug: 243933553
Test: Started prng_seeder from init using the new listen flag
Change-Id: I91b3b2b1fd38cc3d96e19e92b76c8e95788191d5
Merged-In: I91b3b2b1fd38cc3d96e19e92b76c8e95788191d5
(cherry picked from commit ecc14a595809846cd09760d2c59b1fdfa9660ce8)
7 files changed