Skip to content

Commit

Permalink
more robust handling of child process termination on osx
Browse files Browse the repository at this point in the history
  • Loading branch information
jjallaire committed Dec 15, 2011
1 parent 3e19ab1 commit 943639e
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/cpp/core/system/PosixChildProcess.cpp
Expand Up @@ -300,16 +300,22 @@ Error ChildProcess::terminate()
// special code path for pseudoterminal
if (options_.pseudoterminal)
{
// on OSX you can only kill the child process by closing the
// terminal handles
// on OSX you need to close all of the terminal handles to get
// bash to quit, however some other processes (like svn+ssh
// require the signal)
#ifdef __APPLE__
pImpl_->closeAll(false, ERROR_LOCATION);
return Success();
#else
return posixCall<int>(
boost::bind(::killpg, ::getpgid(pImpl_->pid), SIGTERM),
ERROR_LOCATION);
#endif

if (::killpg(::getpgid(pImpl_->pid), SIGTERM) == -1)
{
if (errno == EPERM) // see note below on carve out for EPERM
return Success();
else
return systemError(errno, ERROR_LOCATION);
}
else
return Success();
}
else
{
Expand Down

0 comments on commit 943639e

Please sign in to comment.