Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

ctermid(3s) [ultrix man page]

ctermid(3s)															       ctermid(3s)

Name
       ctermid - generate file name for terminal

Syntax
       #include <stdio.h>

       char *ctermid(s)
       char *s;

Description
       The subroutine generates the pathname of the controlling terminal for the current process, and stores it in a string.

       If  s is a NULL pointer, the string is stored in an internal static area, the contents of which are overwritten at the next call to and the
       address of which is returned.  Otherwise, s is assumed to point to a character array of at least elements.  The pathname is placed in  this
       array  and  the	value of s is returned.  The constant is defined in the <stdio.h> header file.	The difference between and is that must be
       handed a file descriptor and returns the actual name of the terminal associated with that file descriptor, while returns a string ( )  that
       will  refer  to the terminal if used as a file name.  Thus subroutine is useful only if the process already has at least one file open to a
       terminal.

See Also
       ttyname(3)

																       ctermid(3s)

Check Out this Related Man Page

ctermid(3)						     Library Functions Manual							ctermid(3)

NAME
ctermid - Generates the pathname for the controlling terminal LIBRARY
Standard C Library (libc.so, libc.a) SYNOPSIS
#include <stdio.h> char *ctermid( char *s); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: ctermid(): XPG4, XPG4-UNIX Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Points to the array into which the ctermid() function copies the string representing the pathname. DESCRIPTION
The ctermid() function generates a string that, when used as a pathname, refers to the current controlling terminal for the current process. If ctermid() returns a pathname, access to the file is not guaranteed. The ctermid() function differs from the ttyname() function in that the ttyname() function is supplied a file descriptor and returns the actual name of the terminal associated with that file descriptor, while the ctermid() function returns a string (/dev/tty) that refers to the terminal if used as a filename. Thus, the ttyname() function is useful only if the process already has at least one file open to a ter- minal. RETURN VALUES
If the s parameter is not a null pointer, it points to a character array of at least L_ctermid bytes. The pathname is placed in this array and the value of the s parameter is returned. The symbolic constant L_ctermid is defined in the stdio.h header file, and has a value greater than 0 (zero). If the s parameter is a null pointer, the string is stored in an internal static area and the address is returned. The next call to the ctermid() function overwrites the contents of the internal static area. If the pathname that would refer to the controlling terminal cannot be determined, or if the function is unsuccessful, the ctermid() func- tion returns an empty string. RELATED INFORMATION
Functions: ttyname(3) Standards: standards(5) delim off ctermid(3)
Man Page

4 More Discussions You Might Find Interesting

1. Programming

Who is the current user

How could I get the username and password of user, who started this programm? (6 Replies)
Discussion started by: szzz
6 Replies

2. Shell Programming and Scripting

Command Not running in script

Hi Everyone , have a nice day root@sdp01a>SS7Manager -status the problem with above given expression is that i cant add it in script , it only executes if manually given at remote node , can anyone tell me some way to run it in scripts , also i have few more commands aswell , which are for... (2 Replies)
Discussion started by: Dastard
2 Replies

3. Programming

How to find if a process a daemon ?

I have a scenario where I need to find if a process is a daemon process or not. This check needs to be done from within the process. I know there are no direct API's to do so. I have explored these options. 1. ctermid() - this can be unsuccessful as per the man pages 2. int devtty; if ((devtty... (7 Replies)
Discussion started by: vino
7 Replies

4. Programming

scandir() and threads

I couldn't find anywhere informations about it. Is scandir() thread-safe? (4 Replies)
Discussion started by: dawwin
4 Replies