mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Prevent zombie processes (#8774)
Using Systemcall::startscript() with Starttype::DontWait used to create zombie processes, as nobody would collect them. This patch starts those processes as detached, hence preventing them from becoming zombies. In addition to #8774, this bug was also reported here: https://bugs.launchpad.net/ubuntu/+source/lyx/+bug/1096666 Patch from Guy Rutenberg. For reference, see this email thread: http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg180034.html
This commit is contained in:
parent
5b7152a455
commit
5225821242
@ -1475,6 +1475,14 @@ contributers = [
|
||||
"25 September 2007",
|
||||
u"Major rework of the AMS classes"),
|
||||
|
||||
contributer(u"Guy Rutenberg",
|
||||
"guyrutenberg () gmail ! com",
|
||||
"GPL",
|
||||
"Re: [PATCH] Strange Behaivor: xdg-open left as zombie",
|
||||
"m=137365070116624",
|
||||
"12 July 2013",
|
||||
u"System call fixes"),
|
||||
|
||||
contributer(u"Ran Rutenberg",
|
||||
"ran.rutenberg () gmail ! com",
|
||||
"GPL",
|
||||
|
@ -251,19 +251,17 @@ int Systemcall::startscript(Starttype how, string const & what,
|
||||
SystemcallPrivate d(infile, outfile, errfile);
|
||||
|
||||
|
||||
d.startProcess(cmd, path);
|
||||
if (!d.waitWhile(SystemcallPrivate::Starting, process_events, -1)) {
|
||||
d.startProcess(cmd, path, how == DontWait);
|
||||
if (how == DontWait && d.state == SystemcallPrivate::Running) {
|
||||
return 0;
|
||||
}
|
||||
if (d.state == SystemcallPrivate::Error
|
||||
|| !d.waitWhile(SystemcallPrivate::Starting, process_events, -1)) {
|
||||
LYXERR0("Systemcall: '" << cmd << "' did not start!");
|
||||
LYXERR0("error " << d.errorMessage());
|
||||
return 10;
|
||||
}
|
||||
|
||||
if (how == DontWait) {
|
||||
QProcess* released = d.releaseProcess();
|
||||
(void) released; // TODO who deletes it?
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!d.waitWhile(SystemcallPrivate::Running, process_events,
|
||||
os::timeout_min() * 60 * 1000)) {
|
||||
LYXERR0("Systemcall: '" << cmd << "' did not finish!");
|
||||
@ -349,10 +347,18 @@ SystemcallPrivate::SystemcallPrivate(std::string const & sf,
|
||||
}
|
||||
|
||||
|
||||
void SystemcallPrivate::startProcess(QString const & cmd, string const & path)
|
||||
void SystemcallPrivate::startProcess(QString const & cmd, string const & path, bool detached)
|
||||
{
|
||||
cmd_ = cmd;
|
||||
if (process_) {
|
||||
if (detached) {
|
||||
state = SystemcallPrivate::Running;
|
||||
if (!QProcess::startDetached(toqstr(latexEnvCmdPrefix(path)) + cmd_)) {
|
||||
state = SystemcallPrivate::Error;
|
||||
return;
|
||||
}
|
||||
QProcess* released = releaseProcess();
|
||||
delete released;
|
||||
} else if (process_) {
|
||||
state = SystemcallPrivate::Starting;
|
||||
process_->start(toqstr(latexEnvCmdPrefix(path)) + cmd_);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
State state;
|
||||
|
||||
bool waitWhile(State, bool processEvents, int timeout = -1);
|
||||
void startProcess(QString const & cmd, std::string const & path);
|
||||
void startProcess(QString const & cmd, std::string const & path, bool detach);
|
||||
|
||||
int exitCode();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user