[PATCH] init: Add handshake to poweroff/reboot for signal handler setup

Laurent Bercot ska-dietlibc at skarnet.org
Wed Feb 14 02:20:46 UTC 2018


>+					fdrc = connect(fdBB2,
>+					(struct sockaddr *)&bb_addr2,
>+					sizeof(sa_family_t) +
>+						BB_SIGNALS_SOCKET_STR_LEN);
>+					if (fdrc == 0)
>+						break;

  This will not work, because connect() will not succeed if the
server does not listen(). And you cannot listen() in init without
significantly rewriting its execution flow.

  However, you can still use this: connect() on an unbound socket
will return -1 ENOENT, connect() on a bound socket that is not
listening will return -1 ECONNREFUSED. So if you change your
fdrc test to an (errno == ECONNREFUSED) test, it should work.

  See http://lists.busybox.net/pipermail/busybox/2017-October/085893.html
and the whole surrounding thread.

--
  Laurent



More information about the busybox mailing list