Bazaar/SysExec : shortened return time for SysStartAdmin() processes

Now it checks spawned process for termination or name change instead of
doing an heuristic check

git-svn-id: svn://ultimatepp.org/upp/trunk@3071 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
micio 2011-01-23 16:24:08 +00:00
parent 0180027af2
commit 2cfe6fb415

View file

@ -262,16 +262,38 @@ bool SudoExec(String user, String const &password, String const &args, VectorMap
// for example -- maybe it couldn't spawn command
else
{
Sleep(2000);
if(waitpid(pid, &status, WNOHANG))
while(true)
{
// check sudo exit status
if(WIFEXITED(status))
res = (WEXITSTATUS(status) == 0);
else if(WIFSIGNALED(status))
res = true;
else
res = false;
// get spawned process executable file name
FileIn f("/proc/" + FormatInt(pid) + "/cmdline");
String procName = GetFileTitle(f.GetLine());
f.Close();
// check if process is still running
// it should, if all is ok
int waitRes = waitpid(pid, &status, WNOHANG);
// if still running within sudo, continue waiting
if(!waitRes && procName == "sudo")
{
Sleep(100);
continue;
}
// otherwise, if process exited, return its status
else if(waitRes)
{
// check sudo exit status
if(WIFEXITED(status))
res = (WEXITSTATUS(status) == 0);
else if(WIFSIGNALED(status))
res = true;
else
res = false;
return res;
}
// otherwise, process is still running as spawned app
// all is ok, just return true
return true;
}
}