TCPGRP(S) UNIX System V TCPGRP(S)
Name
tcgetpgrp, tcsetpgrp - process group id functions
Syntax
#include <sys/types.h>
pid_t tcgetpgrp (fildes);"
int fildes;
#include <sys/types.h>
int tcsetpgrp (fildes, pgrp_id );"
int fildes;
pid_t pgrp_id;
Description
These routines identify and set the parent process group id
when job control is defined. The tcgetpgrp() function
returns the value of the process group id of the foreground
process group associated with the terminal.
tcgetpgrp() is allowed only from a process that is part of a
background process group. However, this information can be
changed by a process that is part of the foreground process
group by means of the tcsetpgrp() call.
tcsetpgrp() sets the foreground process id group associated
with the terminal to the value of pgrp_id. fildes must be
the file associated with the controlling terminal of the
calling process. The controlling terminal must also be
currently associated with the session of the calling
process. The value of pgrp_id must match a process group id
of a process in the same session as the calling process. Any
other value of pgrp_id will cause an error.
Return Value
If successful, tcgetpgrp() returns the process id of the
foreground process group associated with the calling
terminal. Otherwise, -1 is returned and errno is set to
indicate the error.
tcsetpgrp() returns a value of zero upon success.
Otherwise, -1 is returned and errno is set to indicate the
error.
Errors
If any of the following conditions occur, tcgetpgrp()
returns -1 and sets errno to the corresponding value:
EBADF The fildes argument is not a valid file descriptor.
ENOSYS The tcgetpgrp() function is not supported.
ENOTTY The calling process does not have a controlling
terminal or the file described in fildes is not the
controlling terminal.
If any of the following conditions occur, tcsetpgrp()
returns -1 and sets errno to the corresponding value:
EBADF The fildes argument is not a valid file
descriptor.
EINVAL The value of pgrp_id is not supported.
ENOSYS The tcsetpgrp() function is not supported.
ENOTTY The calling process does not have a
controlling terminal or the file described
in fildes is not the controlling terminal.
EPERM The value of pgrp_id is a value supported
by the implementation but does not match
the process group id of a process in the
same session as the calling process.
See Also
tcflow(S), tcattr(S),
Standards Conformance
tcgetpgrp and tcsetpgrp are conformant with:
IEEE POSIX Std 1003.1-1988 with C Standard Language-
Dependent System Support.
(printed 6/20/89)