slavapestov/factor — Issue #307: io.launcher timeouts are flaky with try-output-process
Author: slavapestov
Created: 2011-10-29 04:38:17+00:00
State: open
Labels: io

try-output-process calls stream-contents before it calls wait-for-process, and it performs both calls in a with-timeout form with the process as the timeout object.

So when we're blocked inside of stream-contents and the timeout period expires, the process is killed. Normally, this should result in the pipes' other end being closed, and stream-contents returning with an EOF.

However, 'git pull' spawns several child processes which inherit standard output. When 'git pull' is killed, these child processes don't seem to die. As a result, they hold on to the pipes, and stream-contents does not receive an EOF. Since there's no timeout on the stream, only on the process, try-output-process can hang forever, even if a timeout period is set.

One problem that needs to be fixed is to have kill-process close the pipes from the factor side. This would solve the issue of stream-contents blocking forever.

However, even if we do this, the bogus subprocesses spawned by 'git pull' will stick around forever, even after try-output-process returns.

So we should change kill-process to close the pipes or otherwise unblock the stream-contents. We should also look into using process groups on Unix, so that all children spawned by the process are killed by kill-process. I'm not sure if there is an equivalent on Windows.