Make svc state transition to RUNNING *before* service_start(), because
in that function we may call service_step() as well, which would start
the svc again (since it was still in READY).
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Only run HOOK_SVC_START on successful start, and *after* having printed
the result of the started service, otherwise any print-outs from plugins
or tasks we start may overwrite the started service's progress.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Don't really see the point of this code anymore, was possibly an issue
before we refactored the logging subsystem. Comment out for now, and
remove later.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
If you have lots of service/run/tasks using the same cmd it's impossible
to tell them apart in debug mode. This patch logs description as well
as cmd to improve on this situation a bit.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch adds a 'once' counter to the svc_t for run/task jobs. This
counter is incremented when Finit calls service_start() and is reset on
runlevel changes.
Also, at the end of a runlevel each run/task have their state reset to
SVC_HALTED_STATE so they can be launched again for the new runlevel, if
so declared.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Systems running OverlayFS, or similar, on /etc may have new/modified
.conf files in /etc/finit.d. This patch makes sure to reload them
after `mount -a` has run so any configured bootstrap tasks and the
new hook callback scripts may run as expected.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch fixes a rather nasty bug in the SIGTERM+SIGKILL logic
employed by Finit when stopping tasks, e.g. at a runlevel change.
When a process terminates, after Finit having sent it SIGTERM, and the
SIGKILL timer expires *before* the timer has been cancelled, then the
timer callback would cause kill(0, SIGKILL).
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch extends the existing rlimit implementation to support setting
limits per service, run/task, inetd, and tty.
Use rlimit in /etc/finit.conf to change the global setting, which is
then inherited to each /etc/finit.d/*.conf. For each .conf file the
rlimit is reinitialized to the global finit.conf settings.
Also, add `unlimited` keyword, to replace the now deprecated `infinity`
keyword. The latter is however kept, for compatibility with previous
releases, for the foreseeable future.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch not only greatly simplifies the registration of the built-in
watchdog daemon, it also fixes a nasty race condition with an external
watchdog daemon. The INIT_CMD_WDOG_HELLO could reach finit in reversed
order, leading to the built-in daemon shutting down, but finit killing
the just registered external daemon.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Most Linux distributions, embedded or otherwise, do not need this
and only confuses the user of an OS with Finit.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Most Linux distributions, embedded or otherwise, do not need this
and only confuses the user of an OS with Finit.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
When alibuEv event watcher callback has `UEV_ERROR` in the events mask
we must handle the error. Unfortunately, in most cases there is not
much we can do but ignore it or log the error.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
If the speed argument to the `tty` stanza is invalid we should not
default to some other random speed. Instead, leave the line speed
as-is, like we do when starting an external getty.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch relocates the speed parser so that exec.c can set the TTY
speed properly as soon as possible. For external getty we make sure
to not touch the TTY speed.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch makes the Finit built-in getty behave a bit more like other
getty implementations. We now not only disable ISIG but also VEOF and
VINTR when prearing the TTY for the getty (built-in or external).
Like before, it is up to the getty process to leave the TTY in a
usable state to /bin/login, so we also move the stty() call to
just before calling /bin/login in getty.c
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch moves the stty() function from getty.c to a separate file so
it can be called from exec.c as well. The fix to #84 is simply to call
stty() in prepare_tty(), which is shared by run_getty() and run_getty2()
and called before "Please press Enter ...".
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Time comparision should be >= not just >. May seem a bit silly to
nitpick like this since we're comparing nano seconds, but on systems
with no high-res timers this happens more often than you would like.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
All this code did was trigger prctl() to set process name to "console",
which you could use as a simple means of figuring out if a process was
started from the system console.
There are other ways to do this, which Finit should not be involved in.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Before we call screen_init(), which in turn calls libite:initscr(),
which in turn does a lot of tcgetattr() and termios to STDOUT to figure
out the size, we need to check that we're not backgrounded, or don't
actually have a TTY. Problem reported by @wkz
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>