mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
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:
parent
0180027af2
commit
2cfe6fb415
1 changed files with 31 additions and 9 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue