Project

General

Profile

Feature #1584

Allow exit codes in CkExit() / ConverseExit()

Added by Matthias Diener about 1 year ago. Updated 22 days ago.

Status:
Implemented
Priority:
Normal
Category:
-
Target version:
Start date:
06/04/2017
Due date:
% Done:

0%


Description

Currently, CkExit() and CkAbort() do not allow passing a custom exit code to the calling shell, making it necessary to use workarounds such as https://charm.cs.illinois.edu/gerrit/#/c/2556/ in order to inform the user.
It would be nice to have this functionality.
Care must be taken since
  1. The method signature should no the changed. CkExit() is currently extern "C" 'ed, so an optional parameter is not possible.
  2. In case multiple PEs call CkExit(), which exit code is reported?

History

#1 Updated by Phil Miller 12 months ago

  • Target version changed from 6.8.1 to 6.9.0

As a core API change, this is not going to be appropriate for a bug-fix/patch release. So, re-targeting for a future feature release.

#2 Updated by Matthias Diener 12 months ago

We could do something like this: https://stackoverflow.com/questions/3046889/optional-parameters-with-c-macros
which would not need an API change.

#3 Updated by Sam White 7 months ago

  • Assignee set to Matthias Diener

#4 Updated by Matthias Diener 5 months ago

  • Target version changed from 6.9.0 to 6.9.1

#5 Updated by Sam White 30 days ago

It would be nice to get this into 6.9.0 since Jozsef Bakosi recently requested it.

#6 Updated by Evan Ramos 30 days ago

Matthias Diener wrote:

We could do something like this: https://stackoverflow.com/questions/3046889/optional-parameters-with-c-macros
which would not need an API change.

I can't seem to make this work with a zero argument instance.

Either way, it is possible to overload a function with C linkage as long as the overload does not also have C linkage. (Tested with GCC, clang, and MSVC.)

#include <stdio.h>

void CkExit(int status)
{
  printf("CkExit(%d);\n", status);
}

extern "C" void CkExit(void)
{
  CkExit(0);
}

int main(void)
{
  CkExit();
  CkExit(1);

  return 0;
}

This still would not allow CkExit with a parameter to be called from C (or Fortran) but for those cases I would propose also adding a void CkExitCode(int status).

#7 Updated by Matthias Diener 30 days ago

Another option would be to always require an exit code for CkExit() (like exit() does), and to change all existing code.

#8 Updated by Evan Ramos 30 days ago

I don't believe changing all existing code would make it out of committee.

#9 Updated by Matthias Diener 30 days ago

  • Target version changed from 6.9.1 to 6.9.0

https://charm.cs.illinois.edu/gerrit/#/c/charm/+/4219/ has a proof-of-concept implementation for CkExit() based on the optional C parameter idea. Seems to work so far, at least on LRTS.

#10 Updated by Sam White 29 days ago

  • Status changed from New to In Progress

#11 Updated by Matthias Diener 22 days ago

  • Status changed from In Progress to Implemented
  • Subject changed from Allow exit codes in CkExit() / CkAbort() to Allow exit codes in CkExit() / ConverseExit()

Also available in: Atom PDF