Try to handle ctrl-z a bit better.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5585 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2019-11-20 09:13:20 +00:00
parent deb756d25b
commit 322754174b
1 changed files with 25 additions and 3 deletions

View File

@ -424,7 +424,7 @@ void Sys_Error (const char *error, ...)
char string[1024];
#ifndef __DJGPP__
// change stdin to non blocking
// change stdin back to blocking, so the shell doesn't bug out.
if (!noconinput)
fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~FNDELAY);
#endif
@ -899,7 +899,7 @@ char *Sys_ConsoleInput(void)
if (!(fl & FNDELAY))
{
fcntl(STDIN_FILENO, F_SETFL, fl | FNDELAY);
Sys_Printf(CON_WARNING "stdin flags became blocking - gdb bug?\n");
// Sys_Printf(CON_WARNING "stdin flags became blocking - gdb bug?\n");
}
}
#endif
@ -907,7 +907,14 @@ char *Sys_ConsoleInput(void)
// if (!qrenderer)
{
if (!fgets(text, sizeof(text), stdin))
{
if (errno == EIO)
{
Sys_Printf(CON_WARNING "Backgrounded, ignoring stdin\n");
noconinput |= 2;
}
return NULL;
}
nl = strchr(text, '\n');
if (!nl) //err? wut?
return NULL;
@ -931,6 +938,15 @@ char *Sys_ConsoleInput(void)
return NULL;
}
#ifdef _POSIX_C_SOURCE
static void SigCont(int code)
{
int fl = fcntl (STDIN_FILENO, F_GETFL, 0);
if (!(fl & FNDELAY))
fcntl(STDIN_FILENO, F_SETFL, fl | FNDELAY);
noconinput &= ~2;
}
#endif
int main (int c, const char **v)
{
double time, oldtime, newtime;
@ -942,6 +958,12 @@ int main (int c, const char **v)
signal(SIGFPE, SIG_IGN);
signal(SIGPIPE, SIG_IGN);
#ifdef _POSIX_C_SOURCE
signal(SIGTTIN, SIG_IGN); //have to ignore this if we want to not lock up when running backgrounded.
signal(SIGCONT, SigCont);
signal(SIGCHLD, SIG_IGN); //mapcluster stuff might leak zombie processes if we don't do this.
#endif
memset(&parms, 0, sizeof(parms));
@ -1018,7 +1040,7 @@ int main (int c, const char **v)
if (!isatty(STDIN_FILENO))
noconinput = !isPlugin; //don't read the stdin if its probably screwed (running in qtcreator seems to pipe stdout to stdin in an attempt to screw everything up).
else
noconinput = COM_CheckParm("-noconinput");
noconinput = COM_CheckParm("-noconinput") || COM_CheckParm("-nostdin");
#ifndef __DJGPP__
if (!noconinput)
fcntl(STDIN_FILENO, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);