Is tcsetattr in Delphi for Linux broken?

I have very simple code doing tcgetattr(STDIN_FILENO,old); tcsetattr(STDIN_FILENO,TCSANOW,old); (using Posix.Unistd and Posix.Termios) and it corrupts my terminal or raises an EAccessViolation.

program setattr;
{$APPTYPE CONSOLE}
{$R *.res}
uses
  // System,
  System.SysUtils,
  Posix.Unistd,
  Posix.Termios;
var
  old, cur: termios;
begin
  try
    { TODO -oUser -cConsole Main : Insert code here }
    writeln('Start');
    tcgetattr(STDIN_FILENO,old);
    cur := old;
    cur.c_iflag := cur.c_iflag and not IXON;
    cur.c_lflag := cur.c_lflag and not (ICANON or ECHO or ISIG or IEXTEN);
    // cfmakeraw(cur);
    cur.c_oflag := cur.c_oflag or OPOST or ONLCR;
    tcsetattr(STDIN_FILENO,TCSANOW,cur);
    writeln('Console semi-raw mode');
    tcsetattr(STDIN_FILENO,TCSANOW,old);
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.