%TTYNAME

%TTYNAME


%SOCKET Index Level %UNLINK
Syntax ptr = (char*)%TTYNAME( fd )
Category BASIC
Type C Function
Description returns a pointer to a static area containing the null terminated path name of the terminal device associated to the file descriptor "fd". If "fd" does not describe a device in the directory "/dev", a NULL pointer is returned.
When run on a phantom process, this function returns a NULL pointer.
Options
See Also c function %OPEN %CLOSE %READ (D3/Unix) %WRITE (D3/Unix) %IOCTL
Example char buffer[32]

* Get the device name associated to our standard input
ptr=(char*)%ttyname( 0 )
if ptr=0 then
* This is not a terminal (pipe?)
 return
end

* Copy the data from the static string to Pick
char buffer[32]
%strcpy( buffer, (char*)ptr )
mytty=field( buffer, char(0), 1)
Warnings The return value points to static data which is overwritten by each call. The name must be copied, as in the example, to a Pick variable.
When run on a phantom process, release 6.0 and earlier versions used to return the parent's terminal name. Release 6.1 and later returns a NULL.
Compatibility D3/Unix
%SOCKET Index Level %UNLINK