Restore tty plugin after tty refactor

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2021-04-15 09:02:28 +02:00
parent 4f40b65f0c
commit eaeddc36c2
2 changed files with 26 additions and 12 deletions
+16 -12
View File
@@ -32,13 +32,14 @@
#include "finit.h"
#include "helpers.h"
#include "plugin.h"
#include "service.h"
#include "tty.h"
static void watcher(void *arg, int fd, int events);
static void tty_watcher(void *arg, int fd, int events);
static plugin_t plugin = {
.io = {
.cb = watcher,
.cb = tty_watcher,
.flags = PLUGIN_IO_READ,
},
};
@@ -55,22 +56,25 @@ static void setup(void)
static void do_tty(char *tty, size_t len, int creat)
{
#if 0
char name[len + 6];
svc_t *entry;
svc_t *svc;
snprintf(name, sizeof(name), "/dev/%s", tty);
entry = svc_find_by_tty(name);
if (entry && tty_enabled(entry)) {
if (creat)
tty_start(entry);
else if (entry->pid)
tty_stop(entry);
svc = svc_find_by_tty(name);
if (svc) {
if (svc_is_blocked(svc) && creat) {
_d("%s: blocked, re-enabling", svc_ident(svc, NULL, 0));
svc_start(svc);
} else if (svc->pid) {
_d("%s: missing ...", svc_ident(svc, NULL, 0));
svc_missing(svc);
}
service_step_all(SVC_TYPE_TTY);
}
#endif
}
static void watcher(void *arg, int fd, int events)
static void tty_watcher(void *arg, int fd, int events)
{
static char ev_buf[8 *(sizeof(struct inotify_event) + NAME_MAX + 1) + 1];
struct inotify_event *ev;
+10
View File
@@ -412,6 +412,16 @@ static int service_start(svc_t *svc)
return 1;
}
if (svc_is_tty(svc)) {
char *dev = tty_canonicalize(svc->dev);
if (!dev || !tty_exists(dev)) {
_d("TTY %s missing or invalid, halting service.", svc->dev);
svc_missing(svc);
return 1;
}
}
if (svc_is_sysv(svc))
logit(LOG_CONSOLE | LOG_NOTICE, "Calling '%s start' ...", svc->cmd);