Project

General

Profile

Bug #1524

wrong SystemCommand exit value

Added by Julian Danner over 3 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Portability
Target version:
Start date:
28 Oct 2020
Due date:
% Done:

100%

Estimated time:
0.66 h
Spent time:

Description

I just noticed that SystemCommand returns incorrect exit values, in particular the returned value is ´exit_val * 256´.

You can check it yourself:


[SystemCommand("exit " + Sprint(e)) | e in 0..255] = (0..255) * 256;


Related issues

Related to CoCoA-5 - Feature #1231: system commandClosed2018-10-26

History

#1 Updated by John Abbott over 3 years ago

  • Category set to Portability
  • Status changed from New to In Progress
  • Target version set to CoCoA-5.4.0
  • % Done changed from 0 to 10

According to cppreference, the return value of std::system is implementation defined.
The CoCoA manual was too specific (and thus wrong).

There is a way to obtain the process exit code on POSIX platforms, but that is not fully portable.

I have revised the CoCoA manual. At the moment the return value of SystemCommand conveys no information.

I wonder: should we change SystemCommand so that it returns NULL? That would make it clear that no information is available.

#2 Updated by John Abbott over 2 years ago

#3 Updated by John Abbott over 2 years ago

  • Status changed from In Progress to Feedback
  • Assignee set to John Abbott
  • % Done changed from 10 to 90

#4 Updated by John Abbott over 2 years ago

My current opinion is to return the exit code, even if this is not well defined (in a portable way).
This would allow someone to use the command in programs for their own use e.g. a return code of 0 may well mean that the command succeeded (on many platforms)

#5 Updated by John Abbott about 2 years ago

  • Status changed from Feedback to Closed
  • % Done changed from 90 to 100
  • Estimated time set to 0.66 h

Julian did report verbally (quite some time ago) that he had had problems with SystemCommand working erratically:
i.e. sometimes working, and sometimes not. I suppose the problem went away... it is hard to debug an intermittent
problem on someone else's computer...

The manual has been updated to clarify that the return value may be platform dependent.

Closing.

Also available in: Atom PDF