cosmetics

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21865 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2007-11-29 20:02:50 +00:00
parent 0ef0cbbf1a
commit b949317f64

View File

@ -34,6 +34,7 @@
# define SIGKILL 9
# include <windows.h>
# include <process.h>
# undef max
#else
# include <csignal>
# include <cstdlib>
@ -72,12 +73,11 @@ public:
//
static void killItDead(int secs, pid_t pid)
{
if (secs > 0) {
if (secs > 0)
new Murder(secs, pid);
} else if (pid != 0) {
else if (pid != 0)
support::kill(pid, SIGKILL);
}
}
//
void kill()
@ -91,20 +91,14 @@ public:
private:
//
Murder(int secs, pid_t pid)
: timeout_(0), pid_(pid)
: timeout_(1000*secs, Timeout::ONETIME), pid_(pid)
{
timeout_ = new Timeout(1000*secs, Timeout::ONETIME);
timeout_->timeout.connect(boost::bind(&Murder::kill, this));
timeout_->start();
timeout_.timeout.connect(boost::bind(&Murder::kill, this));
timeout_.start();
}
//
~Murder()
{
delete timeout_;
}
//
Timeout * timeout_;
Timeout timeout_;
//
pid_t pid_;
};
@ -183,23 +177,19 @@ void ForkedProcess::kill(int tol)
return;
}
// The weird (std::max)(a,b) signature prevents expansion
// of an evil MSVC macro.
int const tolerance = (std::max)(0, tol);
int const tolerance = std::max(0, tol);
if (tolerance == 0) {
// Kill it dead NOW!
Murder::killItDead(0, pid());
} else {
int ret = support::kill(pid(), SIGHUP);
// The process is already dead if wait_for_death is false
bool const wait_for_death = (ret == 0 && errno != ESRCH);
if (wait_for_death) {
if (wait_for_death)
Murder::killItDead(tolerance, pid());
}
}
}