1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-01-14 07:30:21 +00:00

FD_ISSET requires that the fd being tested is >= 0 (#78)

* FD_ISSET requires that the fd being tested is >= 0, so unset fd -1 causes trouble.

* Remove code to enable X I/O signal generation from xinit.c

If the I/O signals are enabled before the signal handler has
been set up, the default action on receipt of a SIGPOLL or SIGIO
will be that the program exits.  For now, turn the signals off,
as they aren't necessary and may not even be an improvement.

* Ensure fds are declared as signed and initialized (to -1)

The global fds may be accessed from the signal handler before any
particular device has been opened.  Ensure that the fds are initialized
statically and that the value is distinguishable from all valid descriptors.

	modified:   initdsp.c
	modified:   initkbd.c
	modified:   keyevent.c
	modified:   osmsg.c
	modified:   rs232c.c
	modified:   timer.c
	modified:   tty.c
This commit is contained in:
Nick Briggs 2020-12-16 22:09:18 -08:00 committed by GitHub
parent 0d4d9a5368
commit fe0f9fff2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 13 additions and 16 deletions

View File

@ -108,8 +108,8 @@ int oldred[2], oldgreen[2], oldblue[2];
#endif /* DISPLAYBUFFER */
#endif /* NOPIXRECT */
int LispWindowFd;
int FrameBufferFd;
int LispWindowFd = -1;
int FrameBufferFd = -1;
int displaywidth, displayheight, DisplayRasterWidth, DisplayType;
int DisplayByteSize;

View File

@ -123,7 +123,7 @@ extern struct screen LispScreen;
#endif /* SUNDISPLAY */
extern int LispWindowFd;
int LispKbdFd;
int LispKbdFd = -1;
extern int errno;
/* for debug */

View File

@ -124,11 +124,11 @@ extern fd_set LispIOFds;
fd_set LispReadFds;
int XNeedSignal = 0; /* T if an X interrupt happened while XLOCK asserted */
extern int LogFileFd;
#ifdef NOETHER
extern u_int LogFileFd;
#else
extern int ether_fd;
extern u_int LogFileFd;
#endif /* NOETHER */
extern DLword *DisplayRegion68k;
@ -316,7 +316,7 @@ getmore:
*/
#ifdef SUNDISPLAY
if (FD_ISSET(LispWindowFd, &rfds)) {
if (LispWindowFd >= 0 && FD_ISSET(LispWindowFd, &rfds)) {
/* #endif */
while (input_readevent(LispWindowFd, &event) >= 0) {
/*if(!kb_event( &event )) {goto getmore;};*/
@ -341,19 +341,19 @@ getmore:
#ifdef NOETHER
#else
if (FD_ISSET(ether_fd, &rfds)) { /* Raw ethernet (NIT) I/O happened, so handle it. */
if (ether_fd >= 0 && FD_ISSET(ether_fd, &rfds)) { /* Raw ethernet (NIT) I/O happened, so handle it. */
DBPRINT(("Handling enet interrupt.\n\n"));
check_ether();
}
#endif /* NOETHER */
#ifdef RS232
if (FD_ISSET(RS232C_Fd, &rfds) || (RS232C_remain_data && rs232c_lisp_is_ready()))
if (RS232C_Fd >= 0 && (FD_ISSET(RS232C_Fd, &rfds) || (RS232C_remain_data && rs232c_lisp_is_ready())))
rs232c_read();
#endif /* RS232 */
#ifdef LOGINT
if (FD_ISSET(LogFileFd, &rfds)) { /* There's info in the log file. Tell Lisp to print it. */
if (LogFileFd >= 0 && FD_ISSET(LogFileFd, &rfds)) { /* There's info in the log file. Tell Lisp to print it. */
flush_pty(); /* move the msg(s) to the log file */
((INTSTAT *)Addr68k_from_LADDR(*INTERRUPTSTATE_word))->LogFileIO = 1;

View File

@ -64,7 +64,7 @@ int log_id;
int previous_size;
int logChanged; /* T if log file has changed since last READ */
/* Set by flush_pty, to avoid the stat call */
u_int LogFileFd;
int LogFileFd = -1;
extern fd_set LispReadFds;
/************************************************************************/

View File

@ -29,7 +29,7 @@ static DLword *RS232CGetCSB, *RS232CPutCSB;
* File descriptor
*/
extern fd_set LispReadFds;
int RS232C_Fd;
int RS232C_Fd = -1;
int RS232C_remain_data;
static char *RS232C_Dev;

View File

@ -460,7 +460,7 @@ int TIMER_INTERVAL = 25000;
int FileIOFlag = 0;
int TimerFlag = 0;
extern u_int LispWindowFd;
extern int LispWindowFd;
/************************************************************************/
/* */

View File

@ -18,7 +18,7 @@ DLTTY_IN_CSB *DLTTYIn;
DLTTY_OUT_CSB *DLTTYOut;
char *TTY_Dev;
int TTY_Fd;
int TTY_Fd = -1;
extern fd_set LispReadFds;
struct sgttyb TTY_Mode;

View File

@ -99,9 +99,6 @@ void init_Xevent(DspInterface dsp)
XSelectInput(dsp->display_id, dsp->SWGrav, GravMask);
XSelectInput(dsp->display_id, dsp->NWGrav, GravMask);
#if defined(OS5) && defined(I_SETSIG)
ioctl(ConnectionNumber(dsp->display_id), I_SETSIG, S_INPUT); /* so we see X events fast */
#endif
} /*end init_Xevent */
/************************************************************************/