Bug 4346 - ioq3ded enters endless loop if stdin is not a tty
Status: RESOLVED FIXED
Alias: None
Product: ioquake3
Classification: Unclassified
Component: Misc
Version: 1.36
Hardware: PC Linux
: P3 normal
Assignee: Zachary J. Slater
QA Contact: ioquake3 bugzilla mailing list
URL:
Depends on:
Blocks:
 
Reported: 2009-11-19 05:46 EST by Andrey Vihrov
Modified: 2009-12-25 18:29:36 EST
2 users (show)

See Also:


Attachments
Working work-around + fix com_speeds output on dedicated server (2.26 KB, patch)
2009-11-19 11:22 EST, Guillaume Bougard

Description Andrey Vihrov 2009-11-19 05:46:47 EST
If ioq3ded is run with stdin not being a tty, it loops soon after printing "stdin is not a tty, tty console mode disabled". strace shows repeated recvfrom() calls, with result being EAGAIN. The problem disappears if +map is added to command line.

Test case:
ioq3ded < /dev/null

Platform:
x86_64 Gentoo Linux
Comment 1 Guillaume Bougard 2009-11-19 11:22:45 EST
Created attachment 2205 [details]
Working work-around + fix com_speeds output on dedicated server

You made me curious even if that case isn't so important.

I found 2 problems.

Firstly, when STDIN is /dev/null, a select on it returns immediately. So in Com_Frame(), Com_Event_Loop() checks are returning after no event found giving many times in the same ms. So it mostly results with a 0ms delay and then will loop checking for new event. Then Com_Event_Loop() will be called as most as possible during 1 ms.

I tried to force a Sys_Sleep() in the loop, but that did nothing... And I found in fact, on Unix, Sys_Sleep() is based on waiting event on STDIN with a timeout. When STDIN is /dev/null, as I said, it returns immediately... So Sys_Sleep() is not useable when stdin is set to /dev/null.

I finally found a way to fix that case when console is disabled using "nanosleep" calls only when console is disabled. It is working on my linux x86_64 system (Fedora 11). I attached the patch. I don't think it is the best, so feel free to enhance it.

Also, I saw com_speeds usage is providing wrong output on dedicated server. The patch contains also a fix for this minor case.
Comment 2 Tim Angus 2009-12-23 19:40:54 EST
Fixed in r1758.
Comment 3 Guillaume Bougard 2009-12-25 18:29:36 EST
Thanks Tim, your fixes are definitively better.