ninja-build/ninja

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

Open

#2,116 建立於 2022年4月2日

在 GitHub 查看
 (2 留言) (0 反應) (0 負責人)C++ (10,194 star) (1,544 fork)batch import
bughelp wanted

描述

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.

貢獻者指南