Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

getpgrp(2) [ultrix man page]

getpgrp(2)							System Calls Manual							getpgrp(2)

Name
       getpgrp - get process group

Syntax
       #include <sys/types.h>
       #include <unistd.h>

       pgrp = getpgrp(pid)
       pid_t pgrp;
       pid_t pid;

Description
       The system call returns the process group of the specified process.  If pid is zero, the call applies to the current process.

       Process	groups	are used for distribution of signals and by terminals to arbitrate requests for their input.  Processes that have the same
       process group as the terminal are the foreground and may read, while others block with a signal if they attempt to read.

       This call is used by programs such as to create process groups in implementing job control.  The TIOCGPGRP and TIOCSPGRP calls described in
       are used to get and set the process group of the control terminal.

Environment
       When  your  program  is	compiled  in  the  System V or POSIX environment, is called without arguments and the process group of the current
       process is returned.

       Additionally, in POSIX mode, returns a value type of pid_t.

Diagnostics
       The call fails under the following condition:

       [ESRCH]	      No such process, PID.

See Also
       getuid(2), setpgrp(2), tty(4)

																	getpgrp(2)

Check Out this Related Man Page

GETPGRP(2)						      BSD System Calls Manual							GETPGRP(2)

NAME
getpgid, getpgrp -- get process group LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <unistd.h> pid_t getpgid(pid_t pid); pid_t getpgrp(void); DESCRIPTION
The process group of the current process is returned by getpgrp(). The process group of the process identified by pid is returned by getpgid(). If pid is zero, getpgid() returns the process group of the current process. Process groups are used for distribution of signals, and by terminals to arbitrate requests for their input: processes that have the same process group as the terminal are foreground and may read, while others will block with a signal if they attempt to read. This call is thus used by programs such as csh(1) to create process groups in implementing job control. The tcgetpgrp() and tcsetpgrp() calls are used to get/set the process group of the control terminal. RETURN VALUES
The getpgrp() call always succeeds. Upon successful completion, the getpgid() call returns the process group of the specified process; oth- erwise, it returns a value of -1 and sets errno to indicate the error. ERRORS
getpgid() will succeed unless: [ESRCH] There is no process whose process ID equals pid. SEE ALSO
getsid(2), setpgid(2), termios(4) HISTORY
The getpgrp() function call appeared in 4.0BSD. The getpgid() function call is derived from its usage in System V Release 4. STANDARDS
The getpgrp() function call is expected to conform to ISO/IEC 9945-1:1990 (``POSIX.1''). COMPATIBILITY
This version of getpgrp() differs from past Berkeley versions by not taking a pid_t pid argument. This incompatibility is required by ISO/IEC 9945-1:1990 (``POSIX.1''). From the ISO/IEC 9945-1:1990 (``POSIX.1'') Rationale: 4.3BSD provides a getpgrp() function that returns the process group ID for a specified process. Although this function is used to support job control, all known job-control shells always specify the calling process with this function. Thus, the simpler AT&T System V UNIX getpgrp() suffices, and the added complexity of the 4.3BSD getpgrp() has been omitted from POSIX.1. The old functionality is available from the getpgid() function. BSD
June 4, 1993 BSD
Man Page

9 More Discussions You Might Find Interesting

1. Programming

do you believe X-application will "kill" the CDE and come back to login dialog

1 . Thanks you for reading the letter 2 . I have programe a X-application .Sometimes, I run it from terminal of CDE ,it "kill" the CDE and I meet the login dialog . I debug it . I find that the SIGHUP caused the X-app died .I do not run it from terminal of CDE ,I run it "click button" from panel ,... (3 Replies)
Discussion started by: chenhao_no1
3 Replies

2. Programming

terminal device control through a C/C++ program

Hi, I want to fork a new process from a daemon that needs terminal attachment to some ttyN or pts/N device. Here is the code #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <sys/stat.h> #include <sys/types.h> #include <string.h> int main(int... (5 Replies)
Discussion started by: ku@ntum
5 Replies

3. Programming

fork() and child processes

Hello, How many child processes are actually created when running this code ? #include <signal.h> #include <stdio.h> int main () { int i ; setpgrp () ; for (i = 0; i < 10; i++) { if (fork () == 0) { if ( i & 1 ) setpgrp () ; printf ("Child id: %2d, group: %2d\n", getpid(),... (0 Replies)
Discussion started by: green_dot
0 Replies

4. Shell Programming and Scripting

fork() and child processes

Hello, How many child processes are actually created when running this code ? #include <signal.h> #include <stdio.h> int main () { int i ; setpgrp () ; for (i = 0; i < 10; i++) { if (fork () == 0) { if ( i & 1 ) setpgrp () ; printf ("Child id: %2d, group: %2d\n",... (1 Reply)
Discussion started by: green_dot
1 Replies

5. Red Hat

SSH problem

Hey, I have a Red Hat 5.2 machine with : 2.6.18-92.el5 kernel PRM's: openssh-4.3p2-29.el5 openssh-clients-4.3p2-29.el5 openssl-0.9.8e-7.el5 openssh-server-4.3p2-29.el5 openssl-0.9.8b-10.el5 openssl-devel-0.9.8e-7.el5 openssh-askpass-4.3p2-29.el5 I'm trying to transfer files to a... (2 Replies)
Discussion started by: eliraza6
2 Replies

6. Shell Programming and Scripting

How can put a background process to the foreground

Hi, guys: I am working on my own shell using c. When I put a process into the background, how can I put it back to the foreground using tcsetpgrp? Thanks (3 Replies)
Discussion started by: tomlee
3 Replies

7. Programming

[C] exec system call

Hi again ;) Now I want to make a program that will execute the programs with exec, asking the user if he wants the program to run in background or foreground. scanf("%c",&caracter); if (caracter=='y'){ printf("Has decidido ejecutarlo en background\n"); if((pid=fork())==0) {// fork para... (3 Replies)
Discussion started by: lamachejo
3 Replies

8. Linux

Sendmail takes too long to start and the host is unable to send emails

Hello All, Sendmail takes too long to start and the host is unable to send emails, below are the steps followed, Please let me know if I'm missing anything, is there a debug mode for mailx? # time service sendmail restart Shutting down sm-client: Shutting... (6 Replies)
Discussion started by: lovesaikrishna
6 Replies

9. Shell Programming and Scripting

Moving XML tag/contents after specific XML tag within same file

Hi Forum. I have an XML file with the following requirement to move the <AdditionalAccountHolders> tag and its content right after the <accountHolderName> tag within the same file but I'm not sure how to accomplish this through a Unix script. Any feedback will be greatly appreciated. ... (19 Replies)
Discussion started by: pchang
19 Replies