mirror of
https://github.com/troglobit/finit.git
synced 2026-10-27 12:20:54 +00:00
Fix #81: Workaround for systems without SYSV shm IPC support
We should not let PID 1 fail on systems where Linux is built without CONFIG_SYSVIPC, or the libc does not support shmget()/shmat(). This workaround implements a fallback to using calloc() for PID 1, which means the initctl tool will not work properly. A better fix would be to refactor the shm implementation to instead have initctl call Finit using api.c for each svc_t. This has been added to the TODO file as future work. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
c1b6c7e840
commit
3d4e3c99ed
1 file changed
+18
-3
@@ -35,14 +35,29 @@
|
|||||||
|
|
||||||
/* Each svc_t needs a unique job# */
|
/* Each svc_t needs a unique job# */
|
||||||
static int jobcounter = 1;
|
static int jobcounter = 1;
|
||||||
|
static svc_t *workaround = NULL;
|
||||||
|
|
||||||
static svc_t *__connect_shm(void)
|
static svc_t *__connect_shm(void)
|
||||||
{
|
{
|
||||||
svc_t *list = finit_svc_connect();
|
svc_t *list;
|
||||||
|
|
||||||
|
list = finit_svc_connect();
|
||||||
|
if (!list) {
|
||||||
|
/* Linux not built with CONFIG_SYSVIPC, or libc does not support shmat()/shmget() */
|
||||||
|
if (ENOSYS == errno)
|
||||||
|
warn("Kernel does support SYSV shmat() IPC, error %d", errno);
|
||||||
|
|
||||||
|
/* Try to prevent PID 1 from aborting, issue #81 */
|
||||||
|
if (getpid() == 1) {
|
||||||
|
warn("Implementing PID 1 workaround, initctl tool will not work ...");
|
||||||
|
if (!workaround)
|
||||||
|
workaround = calloc(MAX_NUM_SVC, sizeof(svc_t));
|
||||||
|
|
||||||
|
list = workaround;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!list) {
|
if (!list) {
|
||||||
/* This should never happen, but if it does we're probably
|
|
||||||
* knee-deep in more serious problems already... */
|
|
||||||
warn("Failed connecting to shared memory, error %d", errno);
|
warn("Failed connecting to shared memory, error %d", errno);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user