Running Subversion post-commit hook as a background process

Solution 1:

I just confirmed this locally. It appears to be by design:

When running hooks, svn calls apr_proc_wait

apr_proc_wait is designed to wait until all child processes exit before returning. This is to avoid zombie(unowned) processes overrunning the system.

You might have some success if you find a way to detach the process (ie, daemon mode), but I'm not sure.

You might find it better to run another process somewhere which does some work in response to a ping from svn - Hudson is my choice for this sort of thing - jobs can be triggered by a wget in a post-commit hook, or you can have it poll subversion for you, depending on what you want to do.

Solution 2:

You need to redirect stderr also:

bash post-commit.bg 2>&1 &

That will detach the process from the parent process (as far as subversion is concerned) and let the client finish without waiting. I had this same problem, and that was the fix.

Solution 3:

On Linux, just use nohup:

nohup sh -c 'sleep 10' &