Ninja waits indefinately on a spawned childs' inherited file descriptor

40 visualitzacions
Ves al primer missatge no llegit

Ian

no llegida,
3 de des. 2020, 10:59:363/12/20
a ninja-build
Hi,

If a task spawns a long-running process then if "pool=console" is used ninja will hang unless that spawned process is either prevented from inheriting file descriptor #4 or closes #4.

Example (Linux):

rule long_process
  command=sleep 600 &> /dev/null &
  # Uncomment pool=console and ninja hangs
  # pool=console
build default: long_process


This works fine until you uncomment pool=console in which case ninja will wait indefinitely.

If the long-running task never inherits fd#4 or knows to close it then all is well again:

rule long_process
  command=sleep 600 4>&- &> /dev/null &
  pool=console
build default: long_process

It seems reasonable that the task and not ninja should be responsible for spawning long-running processes correctly (making sure unknown file descriptors like fd#4 aren't inherited). However it's confusing that using `pool=console` has such a drastic effect and can lead to time-consuming debugging.

Should ninja be able to spot the situation where a task has spawned a long-running process that has been allowed to inherit fd#4? I suppose it might wait till a task's process has finished and if fd#4 is now only held by processes that aren't children of that task then carry on...?

Thanks

Ian


Respon a tots
Respon a l'autor
Reenvia
0 missatges nous