Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions process.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@
#include<sys/types.h>
main()
{
int i,p;
int i,n;
printf("\n pid=%d, ppid=%d",getpid(),getppid());
p=fork();
if(p == 0)
if(n == 0)
{
for(i=0;i<3;i++)
{
printf("\n Child process running,pid=%d,ppid=%d",getpid(),getppid());
printf("\n Child process is running,pid=%d,ppid=%d",getpid(),getppid());
sleep(2);
}
printf("\n Child Exited\n");
sleep(2);
}
else if(p>0)
else if(n>0)
{
for(i=0;i<6;i++)
{
printf("\n Parent process running pid=%d,ppid=%d",getpid(),getppid());
printf("\n Parent process is running pid=%d,ppid=%d",getpid(),getppid());
sleep(2);
}
}
else
printf("\n Error in creating chid process");
printf("\n Error in creating child process");
}


2 changes: 1 addition & 1 deletion semaphore.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ main()
printf("Value after unlocking is %d\n",val1);

if((semctl(sid,0,IPC_RMID) == 0))
printf("Closed the semaphore\n");
printf("Close the semaphore\n");
}