ninja-build/ninja

linux: `pool = console` does not forward signals (e.g. SIGTERM) to the console process

Open

#2116 opened on Apr 2, 2022

View on GitHub
 (2 comments) (0 reactions) (0 assignees)C++ (10,194 stars) (1,544 forks)batch import
bughelp wanted

Description

If I have a simple build.ninja:

rule sleep
  command = $
    echo hi $
    && sleep 100

build sleep : sleep
  pool = console

And I run ninja sleep, I get a process tree like this:

sh (PID: 1)
└─ ninja sleep (PID: 2)
   └─ sleep 100 (PID: 3)

If I now send a SIGTERM to ninja (kill 2), I’d expect that signal to be forwarded to sleep. However, ninja will swallow the signal and nothing happens. The same happens with e.g. SIGINT.

If I remove pool = console, the SIGTERM is forwarded correctly (this was fixed in https://github.com/ninja-build/ninja/pull/743) cc @nicolasdespres


Forwarding signals is quite important if I want to run ninja processes inside a service manager. For example if I want to run ninja sleep (or any program executable I build) inside of s6, s6-supervise will send SIGTERM (or any other signal) to ninja sleep, expecting it to stop running.

Contributor guide