no error thrown with exit(0) in the child process of vfork()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,
I have been trying to create a process using vfork(). And both of the child and the parent process execute it in the same address space. So, if I execute exit(0) in the child process, it should throw some error right. Since the execution is happening in child process first and if I release all the resources by using exit(0) in the child process then parent should be deprived of the resources and should throw some errors right ??
In the following code, however the process ran fine even though I have exit(0) in the child process ........
#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<unistd.h>
int main()
{
    int val,i=0;
    val=vfork();
    if(val==0)
    {
        printf("\nI am a child process.\n");
        printf(" %d ",i++);
        exit(0);
    }
    else
    {
        printf("\nI am a parent process.\n");
        printf(" %d ",i);
    }
    return 0;
}
// The program is running fine .....
But as I have read it should throw some error right ?? I don't know what I am missing . Please point out the point I'm missing. Thanking you in advance.
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux