eloop: catch EINTR in epoll_wait()

epoll_wait() returns EINTR even if using SA_RESTART for signals.
Therefore, catch EINTR and set count to zero.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
hook: delete by callback *and* data argument

When deleting a hook we should not search for the callback only. Otherwise
we might remove the wrong callback. Therefore, we now search for callback
and data argument. If multiple callbacks are registered with the same data
and cb, then we don't care which one is removed as this wouldn't make any
difference. They behave the same way, anyway.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
eloop: add shared signal callbacks

Our current signal source has the problem that a single signal event is
only delivered to one random registered source. This is the design of the
signalfd kernel feature. However, for signals like SIGCHLD it is often
desired to have multiple callbacks. Hence, while keeping the old
signal-source, we now also allow a shared signal source. It is registered
the same way as the old signal source but uses a shared hook.

We may remove the old source so we don't use it in the new implementation.
There are still problems when multiple eloops are used in a single
process and you register the same shared-signum in both eloops. However,
such a design is bad anyway, so we don't care.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
main: use new shared signals

Use the shared signal-implementation instead of the generic signals.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
use pthread_sigmask instead of sigprocmask

pthread is already in our vmem due to our dependencies so link to it
explicitly and use pthread_sigmask to avoid buggy sigprocmask in
multi-threaded applications.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
vt: use new shared signals

Use the new shared-signal backend so we can finally remove the old
signals.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
eloop: remove old signal sources

Remove the old non-shared signal sources in favor of shared-signals.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
pty: fix race when starting child

We should do fork() as the last operation when starting the child.
Currently, if our eloop-add() fails, we have a started child but return
failure to the caller. Therefore, the child will stay alive but we do not
use it.

We now perform all startup correctly before fork()'ing so we are always
safe when starting the child.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
pty: fix wrong fd check

FDs may be 0 so check for >= and not > for fds.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
pty: correctly terminate when child_setup fails

We currently return "ret" when child setup fails, however, we should
rather call exit(). Also avoid cleaning up as this is impossible here
anyway.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
pty: random fixes

Fix some random coding-style issues and adjust to new eloop-rules.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
pty: fix using right fd

Use right fd when spawning child process.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
eloop: wait for all childs

Move child-waiting into the eloop subsystem so all childs are always
correctly freed.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
pty: avoid calling callbacks twice

We shouldn't call the close-cb twice. Therefore, correctly free the FD on
first error, however, keep the signal-callback to get nice log-messages.
Only when the user calls *_close() we eventually stop everything.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
pty: add kmscon_pty_signal()

Allow to send arbitrary signals to the foreground process group of the
pty. Linux supports the TIOCSIG ioctl so we actually do not need to
implement this on our own, yeah!

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
terminal: rework API

We now use the new input/video hooks to avoid waking up the UI all the
time. This reduces the code in the generic UI subsystem and makes the
terminal handle all the stuff.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Bump version number to 1

We use a single version number. The current state seems to be pretty
stable and has all the important features regarding the DRM/input setup.
Only missing stuff is VTE and console.
This is no stable release but rather a first development release.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Update README

Fix some small typos and add TODOs.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>