Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 2 Sep 2012 05:12:58 GMT
From:      "N.Katoh" <typer_jp@yahoo.co.jp>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/171242: x11-driver/xf86-input-mouse: fail to detect moused(8)
Message-ID:  <201209020512.q825Cweq044505@red.freebsd.org>
Resent-Message-ID: <201209020520.q825K42X036001@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         171242
>Category:       ports
>Synopsis:       x11-driver/xf86-input-mouse: fail to detect moused(8)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Sep 02 05:20:04 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     N.Katoh
>Release:        8.3-STABLE
>Organization:
>Environment:
FreeBSD pen4.private 8.3-STABLE FreeBSD 8.3-STABLE #22: Mon Jul  9 01:03:17 JST 2012     root@pen4.private:/usr/local/src/obj/usr/local/src/releng_8/src/sys/PEN4  i386

>Description:
If you do not have a set of Option "Device" in the mouse settings of xorg.conf, is the driver of x.org mouse_drv.so (x11-driver/xf86-input-mouse) will attempt to auto-detect.
[/var/log/Xorg.0.log: (WW) Mouse: No Device specified, looking for one...]

At this time, to detect the use of moused(8), mouse_drv.so use the /dev/sysmouse.
However, in some cases, fail to detect moused(8), may result in errors when attempting to use the device that is already open moused(8).
[/var/log/Xorg.0.log: (EE) Mouse: Cannot open device /dev/ums0]
[/var/log/Xorg.0.log:         Device busy.]

>How-To-Repeat:
Probably use the slow machine or slow storage :-)
>Fix:
Apply the patch attached to x11-driver/xf86-input-mouse.
MousedRunning function of src/bsd_mouse.c of x11-driver/xf86-input-mouse is investigating whether the running moused(8).
How to perform the fstat(1) or pgrep(1) using popen(3),
Although the results are read fscanf(3) may EINTR occurs in read(2) at that time.

Patch attached with submission follows:

--- src/bsd_mouse.c.orig	2012-09-01 21:01:35.568237536 +0900
+++ src/bsd_mouse.c	2012-09-01 21:26:39.917208187 +0900
@@ -302,17 +302,27 @@
     char cmd[128];
     FILE *f = NULL;
     unsigned int i;
+    int ret, j;
 
     if (dev)
 	sprintf(cmd, "sh -c 'fstat %s | grep -c moused' 2>/dev/null", dev);
     else
 	sprintf(cmd, "sh -c 'pgrep -nx moused' 2>/dev/null");
     if ((f = popen(cmd, "r")) != NULL) {
-	if (fscanf(f, "%u", &i) == 1 && i > 0) {
-	    pclose(f);
-	    return TRUE;
+	for (j = 3; j > 0; j--) {
+	    if ((ret = fscanf(f, "%u", &i)) == -1 && ferror(f)) {
+		if (errno == EINTR) {
+		    sleep(1);
+		    continue;
+		}
+		xf86MsgVerb(X_WARNING, 3, "MousedRunning(\"%s\"): Error fscanf: %s\n",
+		    dev, strerror(errno));
+	    }
+	    break;
 	}
 	pclose(f);
+	if (ret == 1 && i > 0)
+	    return TRUE;
     }
     return FALSE;
 }


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201209020512.q825Cweq044505>