Vidalia 0.3.1
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
31class QString;
32
33/** Returns the PID of the current process. */
34qint64 get_pid();
35
36/** Returns true if a process with the given PID is running. */
37bool is_process_running(qint64 pid);
38
39/** Writes the given file to disk containing the current process's PID. */
40bool 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. */
44qint64 read_pidfile(const QString &pidfile, QString *errmsg = 0);
45
46/** Return a list of all currently running PIDs and their associated process
47 * names. */
48QHash<qint64, QString> process_list(quint16 port = 0);
49QHash<qint64, QString> universal_process_list(quint16 port);
50
51/** Attempt to kill process <b>pid</b>. Return true if the specified process
52 * was successfully terminated. Otherwise, return false. */
53bool process_kill(qint64 pid);
54
55#endif
56
qint64 read_pidfile(const QString &pidfile, QString *errmsg=0)
Definition: procutil.cpp:89
QHash< qint64, QString > process_list(quint16 port=0)
Definition: procutil.cpp:112
bool write_pidfile(const QString &pidfile, QString *errmsg=0)
Definition: procutil.cpp:66
QHash< qint64, QString > universal_process_list(quint16 port)
Definition: procutil.cpp:138
qint64 get_pid()
Definition: procutil.cpp:33
bool process_kill(qint64 pid)
Definition: procutil.cpp:118
bool is_process_running(qint64 pid)
Definition: procutil.cpp:44