PAPI  5.0.1.0
fork.c
Go to the documentation of this file.
00001 /* 
00002 * File:    zero_fork.c
00003 * CVS:     $Id$
00004 * Author:  Philip Mucci
00005 *          mucci@cs.utk.edu
00006 * Mods:    <your name here>
00007 *          <your email address>
00008 */
00009 
00010 /* This file performs the following test: start, stop and timer
00011 functionality for a parent and a forked child. */
00012 
00013 #include "papi_test.h"
00014 #include <sys/wait.h>
00015 
00016 int
00017 main( int argc, char **argv )
00018 {
00019     int retval;
00020     int status;
00021 
00022     tests_quiet( argc, argv );  /* Set TESTS_QUIET variable */
00023 
00024     retval = PAPI_library_init( PAPI_VER_CURRENT );
00025     if ( retval != PAPI_VER_CURRENT )
00026         test_fail( __FILE__, __LINE__, "main PAPI_library_init", retval );
00027 
00028     if ( fork(  ) == 0 ) {
00029         retval = PAPI_library_init( PAPI_VER_CURRENT );
00030         if ( retval != PAPI_VER_CURRENT )
00031             test_fail( __FILE__, __LINE__, "forked PAPI_library_init", retval );
00032         exit( 0 );
00033     } else {
00034         wait( &status );
00035         if ( WEXITSTATUS( status ) != 0 )
00036             test_fail( __FILE__, __LINE__, "fork", WEXITSTATUS( status ) );
00037     }
00038 
00039     test_pass( __FILE__, NULL, 0 );
00040     exit( 1 );
00041 }
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines