How to make the parent process wait till the completion of execution of child process. The following C program makes the parent process to wait till the completion of its child process.
#include<stdio.h>
main()
{
Information about resetting and configuring Mobile phones (Java, Android, Symbian etc), educational articles especially for programming in C, C++ and Java and more about Computers and operating systems
Showing posts with label child. Show all posts
Showing posts with label child. Show all posts
C Program to Show Process ID in Linux
This program is to show the process id (pid) in UNIX or Linx
The system call getpid() returns the process id of current process.
#include<stdio.h>
int main()
{
printf("\n Parent Process ID %d",getppid());
}
The system call getpid() returns the process id of current process.
#include<stdio.h>
int main()
{
printf("\n Parent Process ID %d",getppid());
}
Creating A Process in Linux (UNIX) - fork() Example Program
The system call fork() is used to create a new process in UNIX based operating systems and Linux systems. The fork() system call creates a child process when called from a parent process. Unix will make an exact copy of the parent's address space and give it
to the child. Therefore, the parent and child processes have separate
address spaces. Here is a C program which uses the fork() system call to create a process during execution. The program is commented well for better understanding.
Program
/*The program (parent process) reads an array from the user.
It sorts it in descending order.
Program
/*The program (parent process) reads an array from the user.
It sorts it in descending order.
Subscribe to:
Posts
(
Atom
)