This forum has been archived. Please start a new discussion on GitHub.

Signals masked when running under icegridnode?

As a part of our IceGrid installation, I added a "shell server" (written in python) which can start and stop arbitrary processes via subprocess.Popen. (A useful feature, I might add). The processes started properly as:
icegridnode ...
 \_ ...

but shutting them down posed a problem. Not only was it impossible to `kill -INT` them from the IceGrid gui, signals from the command-line were also blocked. Only `kill -TERM` worked.

As a workaround, I now call via a C++ wrapper, containing:
    sigset_t newmask;
    sigprocmask(SIG_SETMASK, &newmask, NULL);
    int ret=execv(argv[1], &argv[1]);

however I'm unclear if this is going to have any detrimental effects. Any suggestions?


  • benoit
    benoit Rennes, France
    Hi Josh,

    Yes, this is a known problem that has already been fixed in the upcoming Ice 3.3. The IceGrid node in 3.2.1 doesn't unmask the signals masked by the Ice::CtrlCHandler class.

    Instead of setting an empty signal mask, you could just unblock the signals blocked by the Ice::CtrCHandler:
            // Unblock signals blocked by IceUtil::CtrlCHandler.
            sigset_t sigs;
            sigaddset(&sigs, SIGHUP);
            sigaddset(&sigs, SIGINT);
            sigaddset(&sigs, SIGTERM);
            sigprocmask(SIG_UNBLOCK, &sigs, 0);

    This is what the IceGrid node is now doing after the fork() system call. If you want to patch and recompile your IceGrid node, you can just add this code to src/IceGrid/Activator.cpp line 636 (after the "if(pid == 0) // Child process.").

  • Excellent, thanks, Benoit. If you don't see any dangers in such, I'll modify my wrapper.cpp rather than distributing a new icegridnode to customers. And I look forward to 3.3.

    Best regards,