Mercurial > hg > easyhg
diff src/common.cpp @ 455:856da063d76e
Remove stale auth cache files
author | Chris Cannam |
---|---|
date | Wed, 29 Jun 2011 16:18:47 +0100 |
parents | 8506333fe65c |
children | 533519ebc0cb |
line wrap: on
line diff
--- a/src/common.cpp Wed Jun 29 15:37:20 2011 +0100 +++ b/src/common.cpp Wed Jun 29 16:18:47 2011 +0100 @@ -31,6 +31,7 @@ #define SECURITY_WIN32 #include <windows.h> #include <security.h> +#include <process.h> #else #include <errno.h> #include <pwd.h> @@ -199,6 +200,30 @@ #endif } +ProcessStatus +GetProcessStatus(int pid) +{ +#ifdef _WIN32 + HANDLE handle = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid); + if (!handle) { + return ProcessNotRunning; + } else { + CloseHandle(handle); + return ProcessRunning; + } +#else + if (kill(getpid(), 0) == 0) { + if (kill(pid, 0) == 0) { + return ProcessRunning; + } else { + return ProcessNotRunning; + } + } else { + return UnknownProcessStatus; + } +#endif +} + FolderStatus getFolderStatus(QString path) { if (path != "/" && path.endsWith("/")) {