fork download
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<unistd.h>
  4. void main(int argc,char*arg[])
  5. {
  6. int pid;
  7.  
  8. if(pid<0)
  9. {
  10. printf("fork failed");
  11. exit(1);
  12. }
  13. else if(pid==0)
  14. {
  15. execip("whoami",Is,Null);
  16. exit(0);
  17. }
  18. else
  19. {
  20. printf("\n Process id is-%d\n",getpid());
  21.  
  22. exit(0);
  23. }
  24. }
  25.  
Success #stdin #stdout 0.03s 25892KB
stdin
Standard input is empty
stdout
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
void main(int argc,char*arg[])
{
	int pid;

	if(pid<0)
	{
		printf("fork failed");
		exit(1);
	}
	else if(pid==0)
	{
		execip("whoami",Is,Null);
		exit(0);
	}
	else
	{
		printf("\n Process id is-%d\n",getpid());

		exit(0);
    }
}