mirror of
https://github.com/troglobit/finit.git
synced 2026-10-11 17:02:42 +07:00
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. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
+10
-4
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user