Sha256: 1d31de1604e672e8965f53790e6c3210786352d98fe0887efedd4c78fcdc3859

Contents?: true

Size: 591 Bytes

Versions: 6

Compression:

Stored size: 591 Bytes

Contents

#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>

/*
 * simple program calling fork
 */
int main(int argc, char **argv)
{
	pid_t child_id;
	pid_t my_id;

	my_id = getpid();
	printf("pid: %d -- I am the parent about to call fork\n",
			(int)my_id);

	child_id = fork();
	if(child_id != 0) {
		my_id = getpid();
		printf("pid: %d -- I just forked a child with id %d\n",
			(int)my_id,
			(int)child_id);
	} else {
		my_id = getpid();
		printf("pid: %d -- I am the child\n",my_id);
	}

	printf("pid: %d -- I am exiting\n",my_id);
	exit(0);

}


Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
jekyll-theme-gaeblogx-0.2 assets/fork-1.c
jekyll-theme-gaeblogx-0.1.5 assets/fork-1.c
jekyll-theme-gaeblogx-0.1.4 assets/fork-1.c
jekyll-theme-gaeblogx-0.1.3 assets/fork-1.c
jekyll-theme-gaeblogx-0.1.1 assets/fork-1.c
jekyll-theme-gaeblogx-0.1.0 assets/fork-1.c