Chapter Contents |
Previous |
Next |
tcgetsid |
Portability: | UNIX compatible |
SYNOPSIS | |
DESCRIPTION | |
RETURN VALUE | |
USAGE NOTES | |
EXAMPLE | |
RELATED FUNCTIONS |
SYNOPSIS |
#include <sys/types.h> #include <termios.h> pid_t tcgetsid(int fileDescriptor);
DESCRIPTION |
The
tcgetsid
function returns the
process group id of the session for which a specific file descriptor is the
controlling terminal. The argument
fileDescriptor
specifies the terminal file descriptor for which the
information is required.
RETURN VALUE |
tcsetgid
returns the process group id for the associated session, or
-1
if it fails (for instance, if the file associated
with
fileDescriptor
is
not a controlling terminal).
USAGE NOTES |
The
tcgetsid
function can only be used with MVS 5.2.2 or a later release.
EXAMPLE |
This example is compiled using
sascc370 -Krent -o
. This program demonstrates the use of the UNIX System
Service function
tcgetsid()
.
/*----------------------------------+ | POSIX/UNIX header files | +----------------------------------*/ #include <sys/types.h> #include <termios.h> #include <errno.h> /*----------------------------------+ | ISO/ANSI header files | +----------------------------------*/ #include <stdlib.h> #include <stdio.h> #include <errno.h> /*----------------------------------+ | Name: main | | Returns: exit(EXIT_SUCCESS) or | | exit(EXIT_FAILURE) | +----------------------------------*/ int main() { /* session leader id for stdin */ pid_t stdin_SID; /* session leader id for stdout */ pid_t stdout_SID; /* session leader id for stderr */ pid_t stderr_SID; /*----------------------------------------*/ /* Get the Session Leader ID for STDIN */ /*----------------------------------------*/ printf("\nGet the Session Leader ID for STDIN\n"); stdin_SID = tcgetsid(STDIN_FILENO); /* Test for Error */ if (stdin_SID == -1) { fprintf(stderr,"Could not get SID for stdin\n"); exit(EXIT_FAILURE); } else { printf(" The Session Leader ID for stdin: %d\n", (int)stdin_SID); } /*--------------------------------------------*/ /* Get the Session Leader ID for STDOUT */ *---------------------------------------------*/ printf("\nGet the Session Leader ID for STDOUT\n"); stdout_SID = tcgetsid(STDOUT_FILENO); /* Test for Error */ if (stdout_SID == -1) { fprintf(stderr,"Could not get SID for stdout\n"); exit(EXIT_FAILURE); } else { printf("The Session Leader ID for stdout: %d\n", (int)stdout_SID); } /*---------------------------------------------*/ /* Get the Session Leader ID for STDERR */ /*---------------------------------------------*/ printf ("\nGet the Session Leader ID for STDERR\n"); stderr_SID = tcgetsid(STDERR_FILENO); /* Test for Error */ if (stderr_SID == -1) { fprintf(stderr,"Could not get SID for stderr\n"); exit(EXIT_FAILURE); } else { printf("The Session Leader ID for stderr: %d\n", (int)stderr_SID); } exit(EXIT_SUCCESS); } /* end of main() */
RELATED FUNCTIONS |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.