Ben Kane added the comment:
https://docs.python.org/3/library/subprocess.html#subprocess.Popen.returncode
does mention the negativeness about returncode in conjunction with POSIX
signals. It would be helpful to mention this Python-specific (I think) behavior
in a comment.
However, returncode
R. David Murray added the comment:
The negative return code indicates the child was terminated by a signal,
exactly as the example error message says. The signal number is the positive
value of the return code. It makes more sense to negate it than it does to
call abs, since we *know* it is
Emanuel Barry added the comment:
A negative return code generally means an error occurred. Negating retcode here
is equivalent to abs(retcode), which shows you want a positive integer to
appear in the message - it's not an error.
Could replace '-retcode' with 'abs(retcode)' to be more clear. P
New submission from Ben Kane:
On page https://docs.python.org/3/library/subprocess.html#replacing-os-system
it looks like the code in the realistic example has a spurious '-' sign.
The line:
print("Child was terminated by signal", -retcode, file=sys.stderr)
shouldn't have the minus sig