View Issue Details

IDProjectCategoryView StatusLast Update
0002827OpenFOAMPatchpublic2018-02-06 11:49
Reportersigveka Assigned Tohenry  
PrioritylowSeveritytrivialReproducibilityhave not tried
Status resolvedResolutionfixed 
PlatformLatitude E7450, Intel i7-5600UOSPop!_OS (Ubuntu derived)OS Version17.10
Fixed in Versiondev 
Summary0002827: Fix possibility of exiting OpenFOAM with any integer error code.
DescriptionWhile attempting to exit FOAM with a specific exit code (integer) I noticed that the resulting error code is always "1" (running in serial mode).

Looking at line 203 of error.C this is obvious because the error code is hard-coded to be 1.
Steps To ReproduceMake a copy of an existing solver, e.g. "laplacianFoam" and a tutorial

mkdir "${HOME}/Desktop/foamExit"; cd "${HOME}/Desktop/foamExit"
cp -r "${FOAM_SOLVERS}/basic/laplacianFoam" "errLaplacianFoam"
cp -r "${FOAM_TUTORIALS}/basic/laplacianFoam/flange" .

Paste the lines below in the main function of the solver and edit the name of the produced executable to "errLaplacianFoam".

Foam::error e("My error");
e.exit(100);

Compile the modified solver, run the example (flage) as follows (the last line prints the exit code):

ansysToFoam flange.ans
errSimpleFoam
echo $?

Additional InformationThe source of this behavior is clearly seen in line 203 of "error.C".
TagsException handling

Activities

henry

2018-02-06 11:49

manager   ~0009265

Resolved in OpenFOAM-dev by commit 15a6365a2a47eba2691c5d4338bf8b8d07792cbd

Issue History

Date Modified Username Field Change
2018-02-06 11:15 sigveka New Issue
2018-02-06 11:15 sigveka Tag Attached: Exception handling
2018-02-06 11:49 henry Assigned To => henry
2018-02-06 11:49 henry Status new => resolved
2018-02-06 11:49 henry Resolution open => fixed
2018-02-06 11:49 henry Fixed in Version => dev
2018-02-06 11:49 henry Note Added: 0009265