summaryrefslogtreecommitdiff
path: root/usr.sbin/moused/moused.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/moused/moused.c')
-rw-r--r--usr.sbin/moused/moused.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/usr.sbin/moused/moused.c b/usr.sbin/moused/moused.c
index 4ed83634090..d23a5af153c 100644
--- a/usr.sbin/moused/moused.c
+++ b/usr.sbin/moused/moused.c
@@ -80,6 +80,7 @@ int background = FALSE;
int identify = ID_NONE;
char *pidfile = "/var/run/moused.pid";
static sigjmp_buf env;
+static jmp_buf restart_env;
/*
* Most of the structures are from the Xfree Project
@@ -416,10 +417,19 @@ freedev(int sig)
errno = save_errno;
}
+static void mouse_init(void);
+
static void
opendev(int sig)
{
- siglongjmp(env, 1);
+ /* re-open the mouse device */
+ if ((mouse.mfd = open(mouse.portname, O_RDWR | O_NONBLOCK, 0)) == -1) {
+ logerr(1, "unable to open %s", mouse.portname);
+ exit(1);
+ }
+ /* re-init the mouse */
+ mouse_init();
+ longjmp(restart_env, 1);
}
static void
@@ -1754,7 +1764,10 @@ moused(void)
}
}
}
-
+
+ /* restart point when coming from X */
+ setjmp(restart_env);
+
/* display initial cursor */
mouse_infos.operation = MOUSE_INIT;