Nominate our 2022 Qt Champions!

App will only run once?

  • A console app I've been writing has been working great cross platform (OS X, Linux, Windows) until recently. Now when I run the app on any platform it will only start the first time it is executed. After the first execution, wether you start as a daemon and kill the process or start on the command line and ctrl-c, the application just returns to the command line. No exit code, no application output. I use QCommandlineParser for version and help information and even those do not respond on the subsequent calls.

    If I was the only one working on the project I'd just back out changes until it worked again, but I've had to merge some branches from others which makes that much more difficult (but I still may need to do this). My searches haven't given me any insight as to what would cause this. Hopefully someone here has an idea.

    It's not visible in the process list and the only thing that seems to work is rebooting the computer and then it will launch on the first try again.

  • Do you use something that tries to limit the number of instances of the program (something like QSingleInstance). Maybe each subsequent attempt to run the program exits since it thinks it is already running?

    If not this then maybe adding a few qDebug commands to see where the program exists.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Before rolling back the changes you merged, you can use the debugger to get some insights of what is going on.

  • I was looking in all the wrong places. So it goes.

    Thanks @Rondog and @SGaist; sometimes you need to rubber duck it from the beginning.

    For archival purposes here is what it was.

    1. Bad practices. The merged code had a QSharedMemory creation and check in there that, unbelievably:
    • returned zero if the creation failed
    • didn't check the error code and take the appropriate action
    • gave no feedback at all that something unwanted happened
    1. Brain fart. I didn't catch the return code because my brain seemed to think that $! echoed the return code instead of $?. So that was my bad and what exacerbated the debugging of the issue.

Log in to reply