Vidalia
0.2.17
|
00001 /* 00002 ** This file is part of Vidalia, and is subject to the license terms in the 00003 ** LICENSE file, found in the top level directory of this distribution. If you 00004 ** did not receive the LICENSE file with this file, you may obtain it from the 00005 ** Vidalia source package distributed by the Vidalia Project at 00006 ** http://www.torproject.org/projects/vidalia.html. No part of Vidalia, 00007 ** including this file, may be copied, modified, propagated, or distributed 00008 ** except according to the terms described in the LICENSE file. 00009 */ 00010 00011 /* 00012 ** \file procutil.h 00013 ** \brief Process information and pidfile functions 00014 */ 00015 00016 #ifndef _PROCUTIL_H 00017 #define _PROCUTIL_H 00018 00019 #include <QtGlobal> 00020 #if defined(Q_OS_WIN) 00021 #include "win32.h" 00022 #else 00023 #include <sys/types.h> 00024 #include <unistd.h> 00025 #include <signal.h> 00026 #include <errno.h> 00027 #endif 00028 00029 #include <QHash> 00030 00031 class QString; 00032 00033 /** Returns the PID of the current process. */ 00034 qint64 get_pid(); 00035 00036 /** Returns true if a process with the given PID is running. */ 00037 bool is_process_running(qint64 pid); 00038 00039 /** Writes the given file to disk containing the current process's PID. */ 00040 bool write_pidfile(const QString &pidfile, QString *errmsg = 0); 00041 00042 /** Reads the giiven pidfile and returns the value in it. If the file does not 00043 * exist, -1 is returned. */ 00044 qint64 read_pidfile(const QString &pidfile, QString *errmsg = 0); 00045 00046 /** Return a list of all currently running PIDs and their associated process 00047 * names. */ 00048 QHash<qint64, QString> process_list(); 00049 00050 /** Attempt to kill process <b>pid</b>. Return true if the specified process 00051 * was successfully terminated. Otherwise, return false. */ 00052 bool process_kill(qint64 pid); 00053 00054 #endif 00055