PAPI  5.0.1.0
forkexec3.c File Reference
Include dependency graph for forkexec3.c:

Go to the source code of this file.

Functions

int main (int argc, char **argv)

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 17 of file forkexec3.c.

{
    int retval;
    int status;

    tests_quiet( argc, argv );  /* Set TESTS_QUIET variable */

    if ( ( argc > 1 ) && ( strcmp( argv[1], "xxx" ) == 0 ) ) {
        retval = PAPI_library_init( PAPI_VER_CURRENT );
        if ( retval != PAPI_VER_CURRENT )
            test_fail( __FILE__, __LINE__, "execed PAPI_library_init", retval );
    } else {
        retval = PAPI_library_init( PAPI_VER_CURRENT );
        if ( retval != PAPI_VER_CURRENT )
            test_fail( __FILE__, __LINE__, "main PAPI_library_init", retval );

        PAPI_shutdown(  );

        if ( fork(  ) == 0 ) {
            retval = PAPI_library_init( PAPI_VER_CURRENT );
            if ( retval != PAPI_VER_CURRENT )
                test_fail( __FILE__, __LINE__, "forked PAPI_library_init",
                           retval );

            if ( execlp( argv[0], argv[0], "xxx", NULL ) == -1 )
                test_fail( __FILE__, __LINE__, "execlp", PAPI_ESYS );
        } else {
            wait( &status );
            if ( WEXITSTATUS( status ) != 0 )
                test_fail( __FILE__, __LINE__, "fork", WEXITSTATUS( status ) );
        }
    }

    test_pass( __FILE__, NULL, 0 );
    exit( 1 );
}

Here is the call graph for this function:

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines