1
0
Fork 0
mirror of https://github.com/pygos/init.git synced 2024-11-05 04:07:10 +01:00

Create init socket after reaching boot target

Filesystem might not be available before then.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
This commit is contained in:
David Oberhollenzer 2018-04-06 23:49:05 +02:00
parent d0764e77b2
commit ffb655126a

View file

@ -196,7 +196,7 @@ static void handle_tellinit(int ti_sock)
int main(void)
{
int ti_sock, sfd, ret;
int ti_sock = -1, sfd, ret, count;
struct pollfd pfd[2];
sigset_t mask;
@ -225,32 +225,37 @@ int main(void)
return EXIT_FAILURE;
}
ti_sock = mksock();
if (ti_sock == -1)
return EXIT_FAILURE;
if (setup_tty())
return EXIT_FAILURE;
memset(pfd, 0, sizeof(pfd));
pfd[0].fd = sfd;
pfd[1].fd = ti_sock;
pfd[0].events = pfd[1].events = POLLIN;
pfd[0].events = POLLIN;
count = 1;
for (;;) {
if (!svclist_have_singleshot() && target != runlevel) {
start_runlevel(target);
runlevel = target;
if (target == TGT_BOOT && ti_sock == -1) {
ti_sock = mksock();
if (ti_sock != -1) {
pfd[1].fd = ti_sock;
pfd[1].events = POLLIN;
count = 2;
}
}
continue;
}
ret = poll(pfd, sizeof(pfd) / sizeof(pfd[0]), -1);
ret = poll(pfd, count, -1);
if (ret > 0) {
if (pfd[0].revents & POLLIN)
handle_signal(sfd);
if (pfd[1].revents & POLLIN)
if (ti_sock != -1 && pfd[1].revents & POLLIN)
handle_tellinit(ti_sock);
}
}