#include <sched.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>

int child( void *arg )
{
	static int thread_count = 0;
	printf ("Thread count = %d\n", thread_count);
	++ thread_count;
	exit( 0 );
}

int main( void )
{
	int i;
	
	for ( i = 0; i < 32768; ++ i )
	{
		if ( fork() == 0 )
			child( NULL );
		if ( waitpid( -1, NULL, 0 ) == -1 )
		{
			return 1;
		}
	}
	
	return 0;
}



