PAPI 7.1.0.0
Loading...
Searching...
No Matches
fork2.c
Go to the documentation of this file.
1/*
2* File: fork2.c
3* Author: Philip Mucci
4* mucci@cs.utk.edu
5* Mods: <your name here>
6* <your email address>
7*/
8
9/* This file performs the following test:
10
11 PAPI_library_init()
12 fork();
13 / \
14 parent child
15 wait() PAPI_shutdown()
16 PAPI_library_init()
17
18 */
19
20#include <stdio.h>
21#include <stdlib.h>
22#include <unistd.h>
23#include <sys/wait.h>
24
25#include "papi.h"
26#include "papi_test.h"
27
28
29int
30main( int argc, char **argv )
31{
32 int retval;
33 int status;
34
35 tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
36
38 if ( retval != PAPI_VER_CURRENT )
39 test_fail( __FILE__, __LINE__, "main PAPI_library_init", retval );
40
41 if ( fork( ) == 0 ) {
43
45 if ( retval != PAPI_VER_CURRENT )
46 test_fail( __FILE__, __LINE__, "forked PAPI_library_init", retval );
47 exit( 0 );
48 } else {
49 wait( &status );
50 if ( WEXITSTATUS( status ) != 0 )
51 test_fail( __FILE__, __LINE__, "fork", WEXITSTATUS( status ) );
52 }
53
54 test_pass( __FILE__ );
55
56 return 0;
57
58}
initialize the PAPI library.
Finish using PAPI and free all related resources.
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
Return codes and api definitions.
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:491
void PAPI_NORETURN test_pass(const char *filename)
Definition: test_utils.c:432
int main()
Definition: pernode.c:20
int retval
Definition: zero_fork.c:53