3

I use the walletnotify and blocknotify config options on bitcoind to have the server call two executables on new transactions/blocks. This all works fine. The two executables (Windows executables) are both designed to run without a console window, and they do.

That is, they do when I run them. When bitcoind runs them, I get a brief flash of a console window. As I run these on my development machine while developing, it's driving me to distraction. Does anyone have any idea to prevent this happening?

1 Answer 1

2

I took me some, but I think I have an answer. I went trough the source code and found the runCommand() function that actually starts the command provided by notify options (it is called mostly from main.cpp and the code runs in a separate thread).

From util.cpp

void runCommand(std::string strCommand)
{
    int nErr = ::system(strCommand.c_str());
    if (nErr)
        LogPrintf("runCommand error: system(%s) returned %d\n", strCommand, nErr);
}

It uses the standard C library method system(), which is probably giving you the flashing window. Normally one would use CreateProcess() (or similar) to prevent the flash effect and have much more control over the spawned process (I don't know why the developers chose system() here, but I guess it was just easier). I believe the behavior of the system() call is system dependent.

Also, when you say bitcoind, you mean the CLI interface of bitcoin, right? Is there a bitcoind console window running? As for a solution, you could edit the source code to use CreateProcess() with the DETACHED_PROCESS flag, that would do the trick.

2
  • I've not yet moved to using 0.9's new bitcoin-cli executable, so I just run bitcoind and talk to it over RPC. So yes, there is a bitcoind console window running. I don't really want to patch the code, so I guess I will just have to live with it. If it annoys me enough I will stick it in a VM :) Thanks for your reply.
    – Avram
    Mar 26, 2014 at 14:32
  • I'm not quite sure what the conditions are for spawning a new shell, but I have seen this being different before on different machines. I for example don't get these flashes, no idea why. I could patch the code for you, but you'd have to recompile yourself (then we know for sure haha). You are welcome.
    – Jori
    Mar 26, 2014 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.