ninja-build/ninja

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

Open

#2116 aperta il 2 apr 2022

Vedi su GitHub
 (2 commenti) (0 reazioni) (0 assegnatari)C++ (1544 fork)batch import
bughelp wanted

Metriche repository

Star
 (10.194 star)
Metriche merge PR
 (Merge medio 39g 3h) (10 PR mergiate in 30 g)

Descrizione

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.

Guida contributor