Zdenek Prikryl wrote:
Hello,
when Gpm_Open() is called in a terminal emulator where $TERM is not xterm, it
returns a file descriptor >= 0 instead of -1. This should happen only on linux
console.
In version 1.20.1 everything works fine, bud not any more in 1.20.5. Gpm_Open()
tries to open /dev/gpmctl. In version 1.20.1 open() fails, bud in 1.20.5 open()
succeeds. I don't look deeply into source code and before I do so, Nico, have
you any idea where can be a bug?
Ok, I found where the problem is. On 1.20.1, there is the test on "text mode".
In 1.20.5 this test is reworked bud not all functionality is ported. So, I'm
sending a patch which corrects it. Please look at it and write your opinion.
Thanks.
Regards.
--
Zdenek Prikryl <zprikryl@xxxxxxxxxx>
diff -up gpm-1.20.5/src/daemon/old_main.c.orig gpm-1.20.5/src/daemon/old_main.c
--- gpm-1.20.5/src/daemon/old_main.c.orig 2008-06-13 10:08:19.000000000 +0200
+++ gpm-1.20.5/src/daemon/old_main.c 2008-10-07 10:01:25.000000000 +0200
@@ -37,12 +37,34 @@
#define max(a,b) ((a)>(b) ? (a) : (b))
#endif
+static int listen_for_clients(void)
+{
+ struct sockaddr_un ctladdr;
+ int ctlfd, len;
+
+ unlink(GPM_NODE_CTL);
+
+ if((ctlfd=socket(AF_UNIX,SOCK_STREAM,0))==-1)
+ gpm_report(GPM_PR_OOPS,GPM_MESS_SOCKET_PROB);
+ bzero((char *)&ctladdr,sizeof(ctladdr));
+ ctladdr.sun_family=AF_UNIX;
+ strcpy(ctladdr.sun_path,GPM_NODE_CTL);
+
+ len=sizeof(ctladdr.sun_family)+strlen(GPM_NODE_CTL);
+ if(bind(ctlfd,(struct sockaddr *)(&ctladdr),len) == -1)
+ gpm_report(GPM_PR_OOPS,GPM_MESS_BIND_PROB,ctladdr.sun_path);
+
+ /* needs to be 0777, so all users can _try_ to access gpm */
+ chmod(GPM_NODE_CTL,0777);
+ listen(ctlfd, 5); /* Queue up calls */
+
+ return ctlfd;
+}
int old_main()
{
int ctlfd, newfd;
- struct sockaddr_un ctladdr;
- int i, len, kd_mode, fd;
+ int i, kd_mode, fd;
struct timeval timeout;
int maxfd=-1;
int pending;
@@ -84,25 +106,12 @@ int old_main()
/* control node */
- if((ctlfd=socket(AF_UNIX,SOCK_STREAM,0))==-1) gpm_report(GPM_PR_OOPS,GPM_MESS_SOCKET_PROB);
- bzero((char *)&ctladdr,sizeof(ctladdr));
- ctladdr.sun_family=AF_UNIX;
- strcpy(ctladdr.sun_path,GPM_NODE_CTL);
- unlink(GPM_NODE_CTL);
-
- len=sizeof(ctladdr.sun_family)+strlen(GPM_NODE_CTL);
- if(bind(ctlfd,(struct sockaddr *)(&ctladdr),len) == -1)
- gpm_report(GPM_PR_OOPS,GPM_MESS_BIND_PROB,ctladdr.sun_path);
+ ctlfd = listen_for_clients();
maxfd=max(maxfd,ctlfd);
-
- /* needs to be 0777, so all users can _try_ to access gpm */
- chmod(GPM_NODE_CTL,0777);
-
get_console_size(&event); /* get screen dimensions */
/*....................................... wait for mouse and connections */
- listen(ctlfd, 5); /* Queue up calls */
#define NULL_SET ((fd_set *)NULL)
#define resetTimeout() (timeout.tv_sec=SELECT_TIME,timeout.tv_usec=0)
@@ -169,8 +178,13 @@ int old_main()
gpm_report(GPM_PR_OOPS,GPM_MESS_IOCTL_KDGETMODE);
close(fd);
if(kd_mode != KD_TEXT && !option.repeater) {
+ close(ctlfd);
+ FD_CLR(ctlfd, &connSet);
wait_text(&mouse_table[1].fd);
- maxfd=max(maxfd,mouse_table[1].fd);
+ ctlfd = listen_for_clients();
+ FD_SET(ctlfd, &connSet);
+ maxfd=max(maxfd,ctlfd);
+ maxfd=max(maxfd,mouse_table[1].fd);
readySet=connSet;
FD_SET(mouse_table[1].fd,&readySet);
continue; /* reselect */
_______________________________________________
gpm mailing list
gpm@xxxxxxxxxxxxxx
http://lists.linux.it/listinfo/gpm