mirror of
https://github.com/troglobit/finit.git
synced 2026-11-27 20:48:24 +00:00
tty: Refactor, remove useless runlevel argument
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
4cc3aed139
commit
963b736d8b
5 files changed
+10
-10
No files matched your search
+1
-1
@@ -72,7 +72,7 @@ static void watcher(void *arg, int fd, int events)
|
|||||||
|
|
||||||
snprintf(name, sizeof(name), "/dev/%s", notified->name);
|
snprintf(name, sizeof(name), "/dev/%s", notified->name);
|
||||||
entry = tty_find(name);
|
entry = tty_find(name);
|
||||||
if (entry && tty_enabled(&entry->data, runlevel)) {
|
if (entry && tty_enabled(&entry->data)) {
|
||||||
if (notified->mask & IN_CREATE)
|
if (notified->mask & IN_CREATE)
|
||||||
tty_start(&entry->data);
|
tty_start(&entry->data);
|
||||||
else if (entry->data.pid)
|
else if (entry->data.pid)
|
||||||
|
|||||||
+2
-2
@@ -434,8 +434,8 @@ int main(int argc, char* argv[])
|
|||||||
/* Enable silent mode before starting TTYs */
|
/* Enable silent mode before starting TTYs */
|
||||||
log_silent();
|
log_silent();
|
||||||
|
|
||||||
/* Start TTYs */
|
/* Delayed start of TTYs at bootstrap */
|
||||||
tty_runlevel(runlevel);
|
tty_runlevel();
|
||||||
|
|
||||||
/* Start new initctl API responder */
|
/* Start new initctl API responder */
|
||||||
api_init(&loop);
|
api_init(&loop);
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ restart:
|
|||||||
|
|
||||||
/* No TTYs run at bootstrap, they have a delayed start. */
|
/* No TTYs run at bootstrap, they have a delayed start. */
|
||||||
if (prevlevel > 0)
|
if (prevlevel > 0)
|
||||||
tty_runlevel(runlevel);
|
tty_runlevel();
|
||||||
|
|
||||||
sm->state = SM_RUNNING_STATE;
|
sm->state = SM_RUNNING_STATE;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ void tty_stop(finit_tty_t *tty)
|
|||||||
tty->pid = 0;
|
tty->pid = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tty_enabled(finit_tty_t *tty, int runlevel)
|
int tty_enabled(finit_tty_t *tty)
|
||||||
{
|
{
|
||||||
if (!tty)
|
if (!tty)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -301,7 +301,7 @@ int tty_respawn(pid_t pid)
|
|||||||
/* Clear PID to be able to respawn it. */
|
/* Clear PID to be able to respawn it. */
|
||||||
entry->data.pid = 0;
|
entry->data.pid = 0;
|
||||||
|
|
||||||
if (!tty_enabled(&entry->data, runlevel))
|
if (!tty_enabled(&entry->data))
|
||||||
tty_stop(&entry->data);
|
tty_stop(&entry->data);
|
||||||
else
|
else
|
||||||
tty_start(&entry->data);
|
tty_start(&entry->data);
|
||||||
@@ -310,12 +310,12 @@ int tty_respawn(pid_t pid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Start all TTYs that exist in the system and are allowed at this runlevel */
|
/* Start all TTYs that exist in the system and are allowed at this runlevel */
|
||||||
void tty_runlevel(int runlevel)
|
void tty_runlevel(void)
|
||||||
{
|
{
|
||||||
tty_node_t *entry;
|
tty_node_t *entry;
|
||||||
|
|
||||||
LIST_FOREACH(entry, &tty_list, link) {
|
LIST_FOREACH(entry, &tty_list, link) {
|
||||||
if (!tty_enabled(&entry->data, runlevel))
|
if (!tty_enabled(&entry->data))
|
||||||
tty_stop(&entry->data);
|
tty_stop(&entry->data);
|
||||||
else
|
else
|
||||||
tty_start(&entry->data);
|
tty_start(&entry->data);
|
||||||
|
|||||||
@@ -54,9 +54,9 @@ size_t tty_num_active (void);
|
|||||||
tty_node_t *tty_find_by_pid (pid_t pid);
|
tty_node_t *tty_find_by_pid (pid_t pid);
|
||||||
void tty_start (finit_tty_t *tty);
|
void tty_start (finit_tty_t *tty);
|
||||||
void tty_stop (finit_tty_t *tty);
|
void tty_stop (finit_tty_t *tty);
|
||||||
int tty_enabled (finit_tty_t *tty, int runlevel);
|
int tty_enabled (finit_tty_t *tty);
|
||||||
int tty_respawn (pid_t pid);
|
int tty_respawn (pid_t pid);
|
||||||
void tty_runlevel (int runlevel);
|
void tty_runlevel (void);
|
||||||
|
|
||||||
#endif /* FINIT_TTY_H_ */
|
#endif /* FINIT_TTY_H_ */
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user