basic.%ttyname

C Function/BASIC Program, Releases: AP/Unix

Returns a pointer to a terminal name.

Syntax

ptr=(char*)%ttyname( fd )

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.

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)

See Also

Command Name Type Description
basic.cfunc Definition can be called from a Pick/BASIC program or subroutine in AP/DOS and AP/Unix implementations using a syntax similar to that of normal C.
basic.%open C Function Opens a Unix file for reading or writing.
basic.%close C Function Closes a Unix file.
basic.%read C Function Reads from a Unix file.
basic.%write C Function Writes to a Unix file.
basic.%ioctl C Function Special IO control.

User Comments

What do you think?

Share your experience or ask a question by using the form below.

Login to leave your comments.