/* * Sample program for getpid system call - No.20 * * getpid, getppid - get process identification * * Synopsis * #include * #include * * pid_t getpid(void); * pid_t getppid(void); * * Description * getpid returns the process ID of the current process. * (This is often used by routines that generate unique * temporary file names.) * * getppid returns the process ID of the parent of the * current process. * * Types - * typedef int pid_t; */ #include main() { int child; child = fork(); wait(NULL); if (child == 0) { printf("Child : "); } else { printf("Parent: "); } printf("my pid = %d, parent's pid = %d\n", getpid(), getppid()); exit(0); }