00001 /**************************************************************** 00002 * Vidalia is distributed under the following license: 00003 * 00004 * Copyright (C) 2006, Matt Edman, Justin Hipple 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 ****************************************************************/ 00021 00022 /** 00023 * \file process.h 00024 * \version $Id: process.h 1244 2006-09-27 02:32:47Z edmanm $ 00025 * \brief Process information and pidfile functions 00026 */ 00027 00028 #ifndef _PROCESS_H 00029 #define _PROCESS_H 00030 00031 #include <QString> 00032 00033 #if defined(Q_OS_WIN) 00034 #include "win32.h" 00035 #else 00036 #include <sys/types.h> 00037 #include <unistd.h> 00038 #include <signal.h> 00039 #include <errno.h> 00040 #endif 00041 00042 00043 /** Returns the PID of the current process. */ 00044 qint64 get_pid(); 00045 00046 /** Returns true if a process with the given PID is running. */ 00047 bool is_process_running(qint64 pid); 00048 00049 /** Writes the given file to disk containing the current process's PID. */ 00050 bool write_pidfile(QString pidfile, QString *errmsg = 0); 00051 00052 /** Reads the giiven pidfile and returns the value in it. If the file does not 00053 * exist, -1 is returned. */ 00054 qint64 read_pidfile(QString pidfile, QString *errmsg = 0); 00055 00056 #endif 00057