[syslinux] COM32: console_ansi_raw() and later segfaults

Gene Cumm gene.cumm at gmail.com
Sat Dec 13 05:45:00 PST 2008


On Wed, Dec 10, 2008 at 7:07 PM, H. Peter Anvin <hpa at zytor.com> wrote:
> Gene Cumm wrote:
>>
>> Based on the <bits/termios.h> in my system, I think only c_lflag
>> should be touched and should also be ORd with ISIG (to allow ^C to
>> break out of the program).
>>
>
> Well, you typically want to leave most the flags unchanged.
>

I can definitely understand that.  As more is touched, it means that
there's a higher probability something unexpected may happen
(especially if the BIOS is buggy).

>
> Note that we have a restorer function which kicks in on exit.  It needs
> to also be called on close.
>

Hmm.... Looking at things, I think I just dove into something that
I've never dealt with (GNU C and module constructors/destructors).
Looks like I should be doing a little more reading before I continue
much further as I'm probably doing something wrong that just happens
to coincidentally work.

It seems like my program should be calling the constructor for
console_ansi_raw() (to save my current settings), console_ansi_raw()
(to manipulate current settings), use getkey(), then call the
destructor for console_ansi_raw() (to restore the settings back to the
original within my program).  I have no idea at the moment if I have
the right direction or how to proceed with this.  Hopefully Google
will be my friend.

On Wed, Dec 10, 2008 at 6:25 PM, H. Peter Anvin <hpa at zytor.com> wrote:
>> Well, I found the issue: console_ansi_std() is touching c_cflag but
>> not c_lflag.  The next question is should it be touching both or just
>> c_lflag?
>>
>
> Setting both is probably a good idea.
>

I can't speak for other POSIX systems (or even other architectures for
Linux) but, on my system, the lower 5 bits seem to control a serial
port's speed (along with 1 other higher bit for speeds starting at
57600;  B57600 and B0 are some search keywords in <bits/termios.h>).
ISIG and ICANON will touch the low 2 bits of c_cflag if used,
potentially changing the serial port speed in Linux (unless I'm
misinterpreting the code).

-Gene




More information about the Syslinux mailing list