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:
parent
d0764e77b2
commit
ffb655126a
1 changed files with 14 additions and 9 deletions
23
initd/main.c
23
initd/main.c
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue