Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2001-10

Crt unit, FreeBSD

6 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Maarten Bekers

hi,

Using the CRT unit of the FreeBSD port of FPC (1.1 compiler), I encountered that programs take a very long time to startup when run over telnet. This problem seems to be caused by TtyName() seemingly to loop endlessly.

Attached is a fix for this problem, but it might be just an fix for a symptom and not the actual issue, anyways.

--snip--
function TTYName(Handle:Longint):string;
{
Return the name of the current tty described by handle f. returns empty string in case of an error.
}
var
mydev,

  myino     : longint;
  st        : stat;
  function mysearch(n:string): boolean;
  {searches recursively for the device in the directory given by n,
    returns true if found and sets the name of the device in ttyname}
  var dirstream : pdir;
      d         : pdirent;
      name      : string;
      st        : stat;
  begin
    dirstream:=opendir(n);
    if (linuxerror0) or (dirstream=nil) then
     exit;
    d:=Readdir(dirstream);
    while (dnil) do
     begin
       name:=n+'/'+strpas(@(d^.name));
       fstat(name,st);
       if linuxerror=0 then
        begin
          if ((st.mode and $E000)=$4000) and  { if it is a directory }
             (strpas(@(d^.name))'.') and    { but not ., .. and fd
subdirs }
             (strpas(@(d^.name))'..') and
             (strpas(@(d^.name))'') and
             (strpas(@(d^.name))'fd') then
           begin                      {we found a directory, search inside
it}
             if mysearch(name) then
              begin                 {the device is here}
                closedir(dirstream);  {then don't continue searching}
                mysearch:=true;
                exit;
              end;
           end
          else if (d^.ino=myino) and (st.dev=mydev) then
           begin
             closedir(dirstream);
             ttyname:=name;
             mysearch:=true;
             exit;
           end;
        end;
       d:=Readdir(dirstream);
     end;
    closedir(dirstream);
    mysearch:=false;
  end;
-cut-

The bug-form seems not to work,
Another thing i found is that i get a lot of error messages that typecasts of a different size are not allowed, while the compiler runs in Delphi compatibility mode.

groeten, Maarten.

Maarten Bekers
to Peter Vreman: If you can provide samples it would be possible to

hoi Peter,

> Another thing i found is that i get a lot of error messages that

typecasts

> of a different size are not allowed, while the compiler runs in Delphi > compatibility mode. If you can provide samples it would be possible to look at it.
<-snip->
program test;
procedure blah(var o: byte);
begin
  o := 12;
end; { proc. blah }
var i: longint;
begin
  i := 11;
  blah(byte(i));
end.
<-snip->

Works in -So, doesnt work in -Sd.
(and i never said it was pretty, did i? :-)

groeten, Maarten.

Maarten Bekers
to Marco van de Voort

hey Marco,

> Using the CRT unit of the FreeBSD port of FPC (1.1 compiler), I

encountered

> that programs take a very long time to startup when run over telnet. > This problem seems to be caused by TtyName() seemingly to loop

endlessly.

I'll try to test that the next couple of days. The bug could also be in GetDir btw, which uses similar code.

Nah, as far as i can tell, this does the correct check (by seeing if the dirname = #0).
This problem also causes some issues on Mandrake 7.0 system where /dev is not always normal listable.

Is there any news yet on a fix? Perhaps just apply the suggested changes so it works?

groeten, Maarten

Marco van de Voort
to Maarten Bekers
Show quoted text 15 lines
> > Using the CRT unit of the FreeBSD port of FPC (1.1 compiler), I encountered > > that programs take a very long time to startup when run over telnet. > > This problem seems to be caused by TtyName() seemingly to loop endlessly. > I'll try to test that the next couple of days. > The bug could also be in GetDir btw, which uses similar code. Nah, as far as i can tell, this does the correct check (by seeing if the dirname = #0). This problem also causes some issues on Mandrake 7.0 system where /dev is not always normal listable. Is there any news yet on a fix? Perhaps just apply the suggested changes so it works?

I thought I already commited that? Will check next week. Probably tomorrow.

(just came back from the HCC, too much new stuff to play with)