Vidalia  0.2.21
procutil.h
Go to the documentation of this file.
1 /*
2 ** This file is part of Vidalia, and is subject to the license terms in the
3 ** LICENSE file, found in the top level directory of this distribution. If you
4 ** did not receive the LICENSE file with this file, you may obtain it from the
5 ** Vidalia source package distributed by the Vidalia Project at
6 ** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7 ** including this file, may be copied, modified, propagated, or distributed
8 ** except according to the terms described in the LICENSE file.
9 */
10 
11 /*
12 ** \file procutil.h
13 ** \brief Process information and pidfile functions
14 */
15 
16 #ifndef _PROCUTIL_H
17 #define _PROCUTIL_H
18 
19 #include <QtGlobal>
20 #if defined(Q_OS_WIN)
21 #include "win32.h"
22 #else
23 #include <sys/types.h>
24 #include <unistd.h>
25 #include <signal.h>
26 #include <errno.h>
27 #endif
28 
29 #include <QHash>
30 
31 class QString;
32 
33 /** Returns the PID of the current process. */
34 qint64 get_pid();
35 
36 /** Returns true if a process with the given PID is running. */
37 bool is_process_running(qint64 pid);
38 
39 /** Writes the given file to disk containing the current process's PID. */
40 bool write_pidfile(const QString &pidfile, QString *errmsg = 0);
41 
42 /** Reads the giiven pidfile and returns the value in it. If the file does not
43  * exist, -1 is returned. */
44 qint64 read_pidfile(const QString &pidfile, QString *errmsg = 0);
45 
46 /** Return a list of all currently running PIDs and their associated process
47  * names. */
48 QHash<qint64, QString> process_list();
49 
50 /** Attempt to kill process <b>pid</b>. Return true if the specified process
51  * was successfully terminated. Otherwise, return false. */
52 bool process_kill(qint64 pid);
53 
54 #endif
55