aboutsummaryrefslogtreecommitdiff
path: root/initd/main.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-04-06 23:49:05 +0200
committerDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-04-07 01:33:58 +0200
commitffb655126a7588ab9e1f56579ea2223f6f04c2ee (patch)
tree5716cc095bc93c64e13018c2e0593566e066d036 /initd/main.c
parentd0764e77b265bc1fc99456ddd3d3e3a088ef1f78 (diff)
Create init socket after reaching boot target
Filesystem might not be available before then. Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'initd/main.c')
-rw-r--r--initd/main.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/initd/main.c b/initd/main.c
index 5f85641..49bbee7 100644
--- a/initd/main.c
+++ b/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);
}
}