Jump to content
The Dark Mod Forums
Alberto Salvia Novella

The game exits with success code even on error

Recommended Posts

How to reproduce:

1. Delete "tdm_fonts01.pk4"

2. Run the game in a terminal.


signal caught: Segmentation fault
About to exit with code 0

Also these errors are printed to stdout, where it should be stderr.

This is relevant because if the game crashes it cannot properly report that to a parent process. Such parent is needed, for example, for running the game with a single installation for all users on an Unix system.

Share this post

Link to post
Share on other sites

I don't mean that.

Command line programs can print its content using two different channels. One is stdout (&1), intended for regular messages, and the other is stderr (&2), for errors. If no channel is specified in the code, the program uses stdout by default:

  • echo "Message"
  • echo "Error" >&2

Also when those programs finish they return an integer value (named ${?}) which signals if it has finished properly or not for following commands. Success always has a value of 0, while any other value signals an error.

These are standard in every single application you see, and allows properly working between different software. For example, if The Dark Mod followed the standard, another application could check if it crashed and log the error:

    if [ ${?} -ne 0 ]; then
        echo "${function}: ${error}" >&2
        exit 1

I have written an application that allows all users in a system to run The Dark Mod with a single system wide folder. That application right now cannot tell when the program crashes. I'm planning to share the software in the case other people find it useful.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...