getsid(2) System Calls getsid(2)NAME
getsid - get process group ID of session leader
SYNOPSIS
#include <unistd.h>
pid_t getsid(pid_t pid);
DESCRIPTION
The getsid() function obtains the process group ID of the process that is the session leader of the process specified by pid. If pid is
(pid_t)0, it specifies the calling process.
RETURN VALUES
Upon successful completion, getsid() returns the process group ID of the session leader of the specified process. Otherwise, it returns
(pid_t)-1 and sets errno to indicate the error.
ERRORS
The getsid() function will fail if:
EPERM The process specified by pid is not in the same session as the calling process, and the implementation does not allow
access to the process group ID of the session leader of that process from the calling process.
ESRCH There is no process with a process ID equal to pid.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
SEE ALSO exec(2), fork(2), getpid(2), getpgid(2), setpgid(2), setsid(2), attributes(5), standards(5)SunOS 5.10 22 Jan 1996 getsid(2)
Check Out this Related Man Page
GETSID(P) POSIX Programmer's Manual GETSID(P)
NAME
getsid - get the process group ID of a session leader
SYNOPSIS
#include <unistd.h>
pid_t getsid(pid_t pid);
DESCRIPTION
The getsid() function shall obtain the process group ID of the process that is the session leader of the process specified by pid. If pid
is (pid_t)0, it specifies the calling process.
RETURN VALUE
Upon successful completion, getsid() shall return the process group ID of the session leader of the specified process. Otherwise, it shall
return (pid_t)-1 and set errno to indicate the error.
ERRORS
The getsid() function shall fail if:
EPERM The process specified by pid is not in the same session as the calling process, and the implementation does not allow access to the
process group ID of the session leader of that process from the calling process.
ESRCH There is no process with a process ID equal to pid.
The following sections are informative.
EXAMPLES
None.
APPLICATION USAGE
None.
RATIONALE
None.
FUTURE DIRECTIONS
None.
SEE ALSO
exec() , fork() , getpid() , getpgid() , setpgid() , setsid() , the Base Definitions volume of IEEE Std 1003.1-2001, <unistd.h>
COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol-
ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE
and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained
online at http://www.opengroup.org/unix/online.html .
IEEE /The Open Group 2003 GETSID(P)
hi, i noticed that the pid of a process can change.. is that true?
like now i do a ps on my terminal.. and there is a list of process with their pids.. and later with the same process, (without qutting and runnign the same process) this time round, their pid are different?
is it true? (2 Replies)
Hi all,
Please look into the following code :
int main()
{
char command;
int pid, ppid;
ppid = getpid(); /* Get the parent pid */
pid = fork(); /* Fork */
if ( pid ==0 )
{
sprintf( command, " gdb a.out %d ", ppid );
printf( "Command line is %s\n", command );
system( command... (3 Replies)
All,
I have a requirement to get the process name of the newly execv'd process.
After getting the complete process name, I need to carry out further operations on that.
Problem so far is how do I retrieve the name of the process ?
There is an API in windows called GetCommandLine. I... (2 Replies)
Hi ALL :
consider the given 2 codes:
//p1.c
#include<stdio.h>
FILE * fp;
main()
{
pid_t pid;
fp=fopen("..........");
// now i am transfering the control to a new process(p2.c).
pid=fork();
if(pid==0)
.....
execl(" p2".....);
....
... (6 Replies)
hi,
by getpid() i will get the pid of the current process.
but how do get the name of this process...
or instead from pid how do i get process name...
is there any way...
thanks in advance.... (2 Replies)
hi all,
Is there a simple script anyone could through out to me, to find the pid of a process given the name. I actually need to bind this pid to a processor set. I would probably put these comamns in a shell script which would have.
a) kick start the executable
b) get the pid
c) bind it to a... (10 Replies)
Hi,
I need to get the pid of a process and have to store the pid in a variable and i want to use this value(pid) of the variable for some process. Please can anyone tell me how to get the pid of a process and store it in a variable. please help me on this.
Thanks in advance,
Amudha (7 Replies)
Hi All,
My target is to find the biggest files opened by any process and from that i have to find process id and the corresponding file also.
To get the process id which is accessing the biggest file in the given file system, i am using the below command.
pid=`lsof -s /home/arun/my_work |... (4 Replies)
Hello everybody!
I wrote the following code:
...
int main()
{
pid_t pid;
for (int i=0;i<100;i++)
{
pid=fork();
if(pid==0)
{execl("md5sum","myprog",NULL);exit(1)}
else if(pid>0)
{ waitpid(pid,&status,0);getrusage(RUSAGE_CHILDREN,&usage);}
The... (3 Replies)
Hi
I need help because I don't know if it is possible to add a find inside a cat.
like I have a file with the pid of the process that use to became zombie. And I have the same pid stored in the var (pid1)
now, I have no clue how to check if the the find finds the pid or even if it's... (2 Replies)
Hi everyone
I am writing a simple shell but the background '&' not working i dont understand
this is my fork
pid_t pid;
pid=fork();
if(pid<0)
{
printf("\nChild process failed.");
exit(1);... (2 Replies)
Hello,
I am running ubuntu14.04
What I am trying to do is restart a process with a shell when pid is dead.
I restored pid nr in a file and check with ps aux | grep -v grep | grep $(cat *.pid)| awk '{ print $2 }'
While surfing on google, I have found an answer saying that restoring pid in a... (2 Replies)