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.vidalia-project.net/. No part of Vidalia, including this file, 00007 ** may be copied, modified, propagated, or distributed except according to the 00008 ** terms described in the LICENSE file. 00009 */ 00010 00011 /* 00012 ** \file procutil.h 00013 ** \version $Id: procutil.h 2571 2008-05-10 04:23:18Z edmanm $ 00014 ** \brief Process information and pidfile functions 00015 */ 00016 00017 #ifndef _PROCUTIL_H 00018 #define _PROCUTIL_H 00019 00020 #include <QString> 00021 00022 #if defined(Q_OS_WIN) 00023 #include "win32.h" 00024 #else 00025 #include <sys/types.h> 00026 #include <unistd.h> 00027 #include <signal.h> 00028 #include <errno.h> 00029 #endif 00030 00031 00032 /** Returns the PID of the current process. */ 00033 qint64 get_pid(); 00034 00035 /** Returns true if a process with the given PID is running. */ 00036 bool is_process_running(qint64 pid); 00037 00038 /** Writes the given file to disk containing the current process's PID. */ 00039 bool write_pidfile(QString pidfile, QString *errmsg = 0); 00040 00041 /** Reads the giiven pidfile and returns the value in it. If the file does not 00042 * exist, -1 is returned. */ 00043 qint64 read_pidfile(QString pidfile, QString *errmsg = 0); 00044 00045 #endif 00046