Article View: comp.emacs
Article #3426Re: select(2) problems with SCO emacs.
From: System
Date: Fri, 31 May 1991 18:43
Date: Fri, 31 May 1991 18:43
122 lines
3597 bytes
3597 bytes
In article <JTSILLAS.91May29084756@sprite.ma30.bull.com> jtsillas@sprite.ma30.bull.com (James Tsillas) writes:
>
>I am having a few problem building emacs using Thomas Roell's X386 (X11R4)
>libraries on our SCO systems. It seems the problem is based on the use of
>HAVE_SELECT. When I build emacs with HAVE_SELECT it fails when trying to
>read from a child process such as 'shell' or 'gnus-tcp'. When I build
>without HAVE_SELECT emacs cannot read from my keyboard. I am using
>SCO Dev.Kit. 3.2.1.
>
I ran into a similar if not identical problem with select and cobbled
together the following code from the X11 R4 distribution, which I
appended to sysdep.c, ifdef'ed for SCO Open Desktop. Hope it helps.
--------------------------------- cut here -----------------------------------
#ifdef SCO_ODT
#include <sys/poll.h>
#define NOFILES_MAX 32
#define MAXSOCKS (NOFILES_MAX)
#define MSKCNT ((MAXSOCKS + 31) / 32)
#if (MSKCNT==1)
#define BITMASK(i) (1 << (i))
#define MASKIDX(i) 0
#endif
#if (MSKCNT>1)
#define BITMASK(i) (1 << ((i) & 31))
#define MASKIDX(i) ((i) >> 5)
#endif
#define MASKWORD(buf, i) buf[MASKIDX(i)]
#define BITSET(buf, i) MASKWORD(buf, i) |= BITMASK(i)
#define BITCLEAR(buf, i) MASKWORD(buf, i) &= ~BITMASK(i)
#define GETBIT(buf, i) (MASKWORD(buf, i) & BITMASK(i))
#define POLLERROR (POLLHUP | POLLNVAL | POLLERR)
#define PFD(fds, i, x) \
{ \
if (fds) \
if (ev & (x)) \
BITSET (fds, i); \
else \
BITCLEAR (fds, i); \
}
#define ERROR(x) \
{ \
errno = x; \
return -1; \
}
/*
simulate BSD select system call with SYSV poll system call
note that efds parameter is not fully supported (or understood)
*/
extern long ulimit();
int
select (nfds, rfds, wfds, efds, timeout)
int nfds;
unsigned long *rfds;
unsigned long *wfds;
unsigned long *efds;
struct timeval *timeout;
{
int i, rc, ev, timevalue;
struct pollfd pfds[NOFILES_MAX];
static long _NOFILE = 0;
if (_NOFILE == 0)
_NOFILE = ulimit(4, (long)0);
if (nfds > _NOFILE)
nfds = _NOFILE; /* make poll happy */
for (i = 0; i < nfds; i++)
{
ev = 0;
if (rfds && GETBIT (rfds, i)) ev |= POLLIN;
if (wfds && GETBIT (wfds, i)) ev |= POLLOUT;
if (ev || (efds && GETBIT (efds, i)))
pfds[i].fd = i;
else
pfds[i].fd = -1;
pfds[i].events = ev;
}
if (timeout)
timevalue = timeout->tv_sec * 1000 + timeout->tv_usec / 1000;
else
timevalue = -1;
if ((rc = poll (pfds, (unsigned long)nfds, timevalue)) > 0)
{
if (!efds)
for (i = 0; i < nfds; ++i)
{
ev = pfds[i].revents;
if (ev & POLLERROR)
ERROR (EBADF);
}
for (i = 0; i < nfds; ++i)
{
ev = pfds[i].revents;
PFD (rfds, i, POLLIN);
PFD (wfds, i, POLLOUT);
PFD (efds, i, POLLERROR);
}
}
return rc;
}
#endif /* SCO_ODT */
--
Mark S. Evans Tandem Telecommunications Systems Inc.
Phone: 214-516-6201 850 E. Central Parkway
Fax: 214-516-6801 Plano, TX 75074
Mail: mse@ttsi.lonestar.org
Technical Details
Message-ID:
<1991May31.184314.5576@ttsi.lonestar.org>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!zaphod.mps.ohio-state.edu!mips!apple!sun-barr!newstop!geraldo.Central.Sun.COM!central!dinosaur!ttsi!rootReferences:
<JTSILLAS.91May29084756@sprite.ma30.bull.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!zaphod.mps.ohio-state.edu!mips!apple!sun-barr!newstop!geraldo.Central.Sun.COM!central!dinosaur!ttsi!root From: root@ttsi.lonestar.org (System) Newsgroups: comp.emacs Subject: Re: select(2) problems with SCO emacs. Message-ID: <1991May31.184314.5576@ttsi.lonestar.org> Date: 31 May 91 18:43:14 GMT References: <JTSILLAS.91May29084756@sprite.ma30.bull.com> Distribution: comp Organization: Tandem Telecommunications Systems Inc. Plano, Tx. Lines: 122