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>

Mailing lists / fpc-devel / 2000-12
8 messages · 4 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
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>
At 00:40 19/12/00 , vous avez écrit:
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)
b> ut
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.
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
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.
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;