[syslinux] COM32: console_ansi_raw() and later segfaults

Gene Cumm gene.cumm at gmail.com
Wed Dec 10 14:22:58 PST 2008


On Mon, Dec 8, 2008 at 11:19 PM, H. Peter Anvin <hpa at zytor.com> wrote:
> Gene Cumm wrote:
>> For the read-only shell that I'm working on, I'm running into a slight
>> snag.  I'm trying to build a paging command (emulating the function of
>> more).  It seems get_key() is probably the best function to use for
>> obtaining just a single key sequence.  On my first run, I tried to
>> call console_ansi_raw(), then get_key() then console_ansi_std() to
>> change it back to a more normal mode.  When I then attempt to use
>> fgets() (in Linux, not syslinux/com32), it segfaults.
>>
>> I then decided to try just tweaking the two local flag bits, ICANON
>> and ECHO and it works fine for Linux but now I'm going to have to
>> write alternate code for the COM32 build, probably by writing a pair
>> of functions to change modes.
>>
>> The question is what should I be doing in order to be more compatible
>> with both Linux and COM32?  Are my initial thoughts completely in the
>> wrong direction?
>>
>
> There are some functions in the libutil directory, but I'm not sure if
> there is anything there that switches mode like you want.  Let me check
> tomorrow.
>

libutil are where console_ansi_raw(), console_ansi_std() and get_key()
come from.  Just looking through the contents of all of the
libutil/include/*.h files and the names of all of libutil/*.c files, I
don't see anything else immediately that appears to refer to the
console.

Just did some more testing.  If I use tcgetattr() to fetch the termios
first, run console_ansi_raw() then use tcsetattr() using the old
settings it works perfectly.  I also tried playing with
console_ansi_std() to get it to clear what console_ansi_raw() did and
I can't seem to find what to tweak, even though they look like they
mirror each other.  I either get it to segfault or not echo the
keystrokes again.

Looking around at the other modes that COM32 can open the console in,
maybe I need to create a better function to do this.




More information about the Syslinux mailing list