Sign in Join

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

Mailing lists / fpc-devel / 2000-12

ttyname

8 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

Alejandro Nestor Vargas

I'v got a little bug to report.

The function ttyname does not work with /dev/pts/* I think it is because the routine has been witten for /dev/<something> but not for /dev/<something>/<otherthing>

Reply by email

Pierre Muller
to Alejandro Nestor Vargas

At 00:40 19/12/00 , vous avez écrit:

Show quoted text 5 lines
I'v got a little bug to report. The function ttyname does not work with /dev/pts/* I think it is because the routine has been witten for /dev/<something> but not for /dev/<something>/<otherthing>

Adding support for /dev/somedir/something seems pretty easy to implement, but are we sure that all tty respect this rule ?

maybe some UniXies use /de/a/v/fg/56
or who knows what ...

Marco, do you know the rules for FreeBSD for instance ?

Reply by email

Marco van de Voort
to Pierre Muller
Show quoted text 14 lines
At 00:40 19/12/00 , vous avez _crit: >I'v got a little bug to report. > >The function ttyname does not work with /dev/pts/* >I think it is because the routine has been witten for /dev/<something> but >not for /dev/<something>/<otherthing> Adding support for /dev/somedir/something seems pretty easy to implement, but are we sure that all tty respect this rule ? maybe some UniXies use /de/a/v/fg/56 or who knows what ... Marco, do you know the rules for FreeBSD for instance ?

/dev/ptyx /dev/ttypx

(physical tty, tele type etc)

But IIRC FreeBSD was also thinking about changing to a pts system.

Still have to dive into terminal for FreeBSD (also for IDE). Haven't done much recently, due to being ill(but am better now)

Reply by email

Peter Vreman
Show quoted text 5 lines
At 00:40 19/12/00 , vous avez �crit: >I'v got a little bug to report. > >The function ttyname does not work with /dev/pts/* >I think it is because the routine has been witten for /dev/<something>

b> ut

Show quoted text 9 lines
>not for /dev/<something>/<otherthing> Adding support for /dev/somedir/something seems pretty easy to implement, but are we sure that all tty respect this rule ? maybe some UniXies use /de/a/v/fg/56 or who knows what ... Marco, do you know the rules for FreeBSD for instance ?

Only /dev/pts/* should be supported as that is the new standard instead of the old /dev/ptyp* files

Reply by email

Marco van de Voort
to Peter Vreman
Show quoted text 7 lines
> maybe some UniXies use /de/a/v/fg/56 > or who knows what ... > > Marco, do you know the rules for FreeBSD for instance ? Only /dev/pts/* should be supported as that is the new standard instead of the old /dev/ptyp* files

No. It should be default (and fall back), but afaik you can still turn off /dev/pts (Unix98 TTY support) in the kernel.

This could be the case for bootdisks, firewalls etc, and FPC programs should run there too!

Reply by email

Peter Vreman
Show quoted text 13 lines
> > maybe some UniXies use /de/a/v/fg/56 > > or who knows what ... > > > > Marco, do you know the rules for FreeBSD for instance ? > > Only /dev/pts/* should be supported as that is the new standard instead of the old > /dev/ptyp* files No. It should be default (and fall back), but afaik you can still turn off /dev/pts (Unix98 TTY support) in the kernel. This could be the case for bootdisks, firewalls etc, and FPC programs should run there too!

Sorry, i was unclear, only /dev/pts/* should be added as first try. The others should stay as they are.

Reply by email

Alejandro Nestor Vargas
to Pierre Muller: At 00:40 19/12/00 , vous avez écrit: Adding support for /dev/somedir/something seems…
>The function ttyname does not work with /dev/pts/* >I think it is because the routine has been witten for /dev/<something>

but

Show quoted text 7 lines
>not for /dev/<something>/<otherthing> Adding support for /dev/somedir/something seems pretty easy to implement, but are we sure that all tty respect this rule ? maybe some UniXies use /de/a/v/fg/56 or who knows what ...

Right now I found the problem with RedHat Linux with kernel 2.2.16 with the /dev/pts/* that is the replacement for the old format /dev/ttyp. This is not the first time I´ve seen pts was some years ago (I think 5) in Data General UX.

I know that adding support for this is easy. I can do this if I have the time, but today I cannot promise anything. Then I report the problem and if you don't solve it until I have some time, I will do it.

Reply by email

Alejandro Nestor Vargas
to Pierre Muller: At 00:40 19/12/00 , vous avez écrit: Adding support for /dev/somedir/something seems…

Some days ago I reported a problem with ttyname function (it does not work for /dev/pts/*). I made a modification to the function. If you consider it is correct you could put it in further versions of linux (or unix) unit. Here is the code:

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) 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)  { if it is a directory }
          and (strpas(@(d^.name))'.')   {but not ., .. and fd subdirs}
          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;
begin
  TTYName:='';
  fstat(handle,st);
  if (errno0) and isatty (handle)
  then exit;
  mydev:=st.dev;
  myino:=st.ino;
  mysearch('/dev');
end;

Reply by email