EINTR select() - also fd null upon daemon restart

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

This was sent Tue, 18 Mar 2008 but rejected (probably sent from wrong email).

I had to modify libcurses.c from gpm-1.20.3pre3.  We use alarm() to update the screen every 10 seconds.  This was causing select() to return -1 (errno=EINTR).  I had to move the test for (flag==-1) before FD_ISSET().  I couldn't combine the (!flag) and (flag==-1) tests because I need the GPM_DRAWPOINTER() call.  I believe this applies anywhere select() is called ("sets and timeout become undefined" on error).

Also, I added tests for fd<0 and gpm_fd<0.  One of these is < 0 if the gpm daemon is restarted.  Should gpm_hflag=1 before return?

Thanks

Stan Dickerson
Energy Control Systems

Here is the revised section of libcurses.c:


/*...................................................................*/
  if (gpm_fd>=0)                                            /* linux */
    while(1)
      {
      if (gpm_visiblepointer) GPM_DRAWPOINTER(&ev);
      do
    {
    FD_ZERO(&selSet);
    if (fd < 0) return -1;    // added by ECS 2/28/08 for daemon restart
    FD_SET(fd,&selSet);
    if (gpm_fd < 0) return -1;    // added by ECS 2/28/08 for daemon restart
    FD_SET(gpm_fd,&selSet);
    gpm_timeout.tv_sec=SELECT_TIME;
    flag=select(max+1,&selSet,(fd_set *)NULL,(fd_set *)NULL,&gpm_timeout);
    }
      while (!flag);

      if (flag==-1)        // moved before FD_ISSET() by ECS 2/28/08
    continue;

      
      if (FD_ISSET(fd,&selSet))
    return GET(win);

-- 
Stan Dickerson
Energy Control Systems, Inc.
2940 Cole Court
Norcross, GA 30071
1-800-648-0970
770-448-0651
770-446-1319 fax
_______________________________________________
gpm mailing list
gpm@xxxxxxxxxxxxxx
http://lists.linux.it/listinfo/gpm

[Index of Archives]     [Kernel Development]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Gimp]     [Yosemite News]