initctl: allow client_connect() to return error
This lets any callers of client_connect() decide what to do wrt. error
recovery and fallback mechanisms.  E.g., reboot may want to check if
it's in sulogin mode, or fall back to sending signals to PID 1.
@@ -39,11 +39,17 @@ int client_connect(void)
};
sd = socket(AF_UNIX, SOCK_SEQPACKET, 0);
- if (-1 == sd)
- err(1, "Failed creating UNIX domain socket");
+ if (-1 == sd) {
+ warn("Failed creating UNIX domain socket");
+ return -1;
+ }
- if (connect(sd, (struct sockaddr*)&sun, sizeof(sun)) == -1)
- err(1, "Failed connecting to finit");
+ if (connect(sd, (struct sockaddr*)&sun, sizeof(sun)) == -1) {
+ if (errno != ENOENT)
+ warnx("Failed connecting to finit");
+ close(sd);
+ return -1;
+ }
return sd;
}
