[gpm] Return value from Gpm_Open()
Nico Schottelius
nico-gpm@schottelius.org
Tue Oct 7 12:19:55 CEST 2008
Bit busy - as usual - now due to moving my home -
will keep it in queue, check it and apply/reject it for next stable -
expect answer before end of year.
Nico
Zdenek Prikryl [Tue, Oct 07, 2008 at 10:13:22AM +0200]:
> 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@redhat.com>
>
> 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@lists.linux.it
> http://lists.linux.it/listinfo/gpm
--
Think about Free and Open Source Software (FOSS).
http://nico.schottelius.org/documentations/foss/the-term-foss/
PGP: BFE4 C736 ABE5 406F 8F42 F7CF B8BE F92A 9885 188C
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://lists.linux.it/pipermail/gpm/attachments/20081007/f7b46ab8/attachment.pgp
More information about the gpm
mailing list