Sponsored Content
Full Discussion: Help for getpid()
Top Forums Programming Help for getpid() Post 302089936 by Himesh Jain on Thursday 21st of September 2006 01:25:47 PM
Old 09-21-2006
Error Help for getpid()

can anyone tell me the program about how to implement a routine similar to getpid() in C program without using the function getpid(). ie. the program has to find out the pid of the process without using the getpid command. Please do help me in this regards at the earliest.
 

We Also Found This Discussion For You

1. Shell Programming and Scripting

Error while using getpid() is shell script

Hi, I am trying to use getpid() in a k-shell script. However, the script is crashing as it is unable to recognise it as a function. Please guide me on how to use it inside a shell script. (5 Replies)
Discussion started by: sam_roy
5 Replies
getpid(2)							   System Calls 							 getpid(2)

NAME
getpid, getpgrp, getppid, getpgid - get process, process group, and parent process IDs SYNOPSIS
#include <unistd.h> pid_t getpid(void); pid_t getpgrp(void); pid_t getppid(void); pid_t getpgid(pid_t pid); DESCRIPTION
The getpid() function returns the process ID of the calling process. The getpgrp() function returns the process group ID of the calling process. The getppid() function returns the parent process ID of the calling process. The getpgid() function returns the process group ID of the process whose process ID is equal to pid, or the process group ID of the calling process, if pid is equal to 0. RETURN VALUES
Upon successful completion, these functions return the process group ID. Otherwise, getpgid() returns (pid_t)-1 and sets errno to indicate the error. ERRORS
The getpgid() function will fail if: EPERM The process whose process ID is equal to pid is not in the same session as the calling process, and the implementation does not allow access to the process group ID of that process from the calling process. ESRCH There is no process with a process ID equal to pid. The getpgid() function may fail if: EINVAL The value of the pid argument is invalid. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Async-Signal-Safe | +-----------------------------+-----------------------------+ SEE ALSO
intro(2), exec(2), fork(2), getsid(2), setpgid(2), setpgrp(2), setsid(2), signal(3C), attributes(5), standards(5) SunOS 5.10 28 Dec 1996 getpid(2)
All times are GMT -4. The time now is 09:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy