Revert new experimental libev backend due to time constraints

Due to time constraints I had to revert the new libev backend to the
service, I/O and signals monitor.  Employed instead is the tried and
tested signals based service monitor, with a small extension for an
additional I/O monitor using poll() for the I/O plugins to use.

Tried restoring the startx finit.conf directive on top of the service
implementation. However, it's currently not usable to run /usr/bin/startx
for any other user than root. I recommend using the examples/finit.conf
and run /usr/sbin/gdm instead.

finit.c:
        New run_loop() function, replaces libev ev_run().

helpers.c:
        Refactor start_process() into svc_start().

plugin.c:
        Add fds[] array for use in the io_monitor() called by the
        new run_loop().

signal.c:
        Ignore SIGCHLD. Handled by waitpid() in svc_monitor() now,
        which is called by the new run_loop().

svc.c:
        svc_register(): Optional @username parsing for the command line.
        svc_monitor(): Replaced libev callback with waitpid()
        svc_start(): Refactored to use most of helpers.c:start_process()

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2012-09-26 12:18:54 +02:00
1 parent 75eb5cc043
commit c49d89dfe0
13 files changed
+198 -131

No files matched your search

+3 -32
View File
@@ -174,37 +174,6 @@ int print_result(int fail)
return fail;
}
int start_process(char *cmd, char *args[], int console)
{
pid_t pid;
if (sig_stopped())
return 0;
pid = fork();
if (!pid) {
int i;
struct sigaction sa;
/* Reset signal handlers that were set by the parent process */
for (i = 1; i < NSIG; i++)
DFLSIG(sa, i, 0);
if (console) {
int fd = open (CONSOLE, O_WRONLY | O_APPEND);
if (-1 != fd) {
dup2(STDOUT_FILENO, fd);
dup2(STDERR_FILENO, fd);
}
}
execvp(cmd, args);
exit(!console ? print_result(0) : 0);
}
return pid;
}
int run(char *cmd)
{
int status, result, i = 0;
@@ -353,12 +322,14 @@ pid_t run_getty(char *cmd, char *argv[])
sigset_t nmask;
struct sigaction sa;
/* Detach from initial controlling TTY */
vhangup();
close(2);
close(1);
close(0);
/* Attach TTY to console */
if (open(CONSOLE, O_RDWR) != 0)
exit(1);
@@ -479,7 +450,7 @@ int getuser(char *s)
{
struct passwd *usr;
if ((usr = getpwnam(s)) == NULL)
if (!s || (usr = getpwnam(s)) == NULL)
return -1;
return usr->pw_uid;