ref: refs/heads/SuSE-Code-11-Branch
commit bbb53fae65d1c0e304be795d1696c22ac9545d36
Author: Michael Andres
Date: Thu Mar 5 14:56:30 2009 +0100
Remove a lock if the locking process is in zombie state. (bnc #481577)
---
zypp/ZYppFactory.cc | 32 ++++++++++++++++----------------
1 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/zypp/ZYppFactory.cc b/zypp/ZYppFactory.cc
index 85bddd4..5c38f6d 100644
--- a/zypp/ZYppFactory.cc
+++ b/zypp/ZYppFactory.cc
@@ -172,27 +172,27 @@ namespace zypp
{
// it is another program, not me, see if it is still running
Pathname procdir( "/proc"/str::numstring(pid_r) );
-
- PathInfo status( procdir/"status" );
+ PathInfo status( procdir );
MIL << "Checking " << status << endl;
- bool still_running = status.isExist();
- if ( still_running )
+ if ( ! status.isDir() )
{
- Pathname p( procdir/"exe" );
- _locker_name = filesystem::readlink( p ).asString();
- MIL << p << " -> " << _locker_name << endl;
-
- p = procdir/"cmdline";
- MIL << p << ": ";
- std::ifstream infile( p.c_str() );
- for( iostr::EachLine in( infile ); in; in.next() )
- {
- MIL << *in << endl;
- }
+ DBG << "No such process." << endl;
+ return false;
+ }
+
+ static char buffer[513];
+ buffer[0] = buffer[512] = 0;
+ // man proc(5): /proc/[pid]/cmdline is empty if zombie.
+ if ( std::ifstream( (procdir/"cmdline").c_str() ).read( buffer, 512 ).gcount() > 0 )
+ {
+ _locker_name = buffer;
+ DBG << "Is running: " << _locker_name << endl;
+ return true;
}
- return still_running;
+ DBG << "In zombie state." << endl;
+ return false;
}
pid_t lockerPid()
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org