From f0377a641080105502bcd77d059ec698c25f8769 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Tue, 6 May 2025 15:07:32 -0400 Subject: add multiple instance warning if the device is busy. --- TODO | 2 +- marsond.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index 1255a25..2d1f969 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,6 @@ - actual realtime scheduling (maybe). sched(7). - use a log file instead of stderr, so we can have error/warning messages after detaching from the tty. -- find out what happens if we try to run a 2nd instance. - print our /dev/input/event* node name, if possible. - options to set the virtual device name and vendor/product IDs. - much as I hate systemd, get someone to write a systemd unit. @@ -10,3 +9,4 @@ that means another instance is already running... so either exit or pass a command to it (like "marsond -K" would kill an existing instance). +- 'make install' should install README and TODO. diff --git a/marsond.c b/marsond.c index f872baf..b94883b 100644 --- a/marsond.c +++ b/marsond.c @@ -235,6 +235,8 @@ int main(int argc, char **argv) { if(ioctl(infd, EVIOCGRAB, 1) >= 0) { debug("grabbed %s", keyboard_dev); } else { + if(errno == EBUSY) + warn("is an instance of %s already running?", self); die("failed to grab %s: %s", keyboard_dev, strerror(errno)); } @@ -272,7 +274,6 @@ int main(int argc, char **argv) { die("UI_DEV_CREATE failed: %s", strerror(errno)); } - /* this must be done while still running as root... */ if(foreground) { lock_memory(); -- cgit v1.2.3