Updated: April 19, 2023 |
Get the process group ID associated with a device
#include <unistd.h> pid_t tcgetpgrp( int filedes );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The tcgetpgrp() function returns the process group ID of the foreground process that's associated with the device indicated by filedes.
If there's no foreground process group, tcgetpgrp() returns a value greater than 1 that doesn't match the process group ID of any existing process group.
You can call tcgetpgrp() from a process that's a member of a background process group, but the information may be subsequently changed by a process that's a member of a foreground process group.
The ID of foreground process group. If an error occurs, -1 is returned, and errno is set.
#include <sys/types.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> int main( void ) { printf( "STDIN directs breaks to pgrp %d\n", tcgetpgrp( 0 ) ); return EXIT_SUCCESS; }
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |