/*
 * This file is part of DesktopBSD, see the README file.
 *
 * Author: Peter Hofer <ph@desktopbsd.net>
 *         (C) 2004, 2005
 *
 * Copyright: BSD, see the COPYING file included in this distribution
 *
 */

#ifndef __UNIXPROCESS_H
#define __UNIXPROCESS_H

#include <qprocess.h>

/** @brief QProcess customized for UNIX systems.
  *
  * This process implementation provides some extra
  * functionality for killing processes and whole
  * process groups.
  */
class UnixProcess : public QProcess {
	Q_OBJECT

public:
	UnixProcess(QObject * parent = 0, const char * name = 0);
	UnixProcess(const QString & arg0, QObject * parent = 0, const char * name = 0);
	UnixProcess(const QStringList & args, QObject * parent = 0, const char * name = 0);
	
	QStringList arguments() const;
	QStringList arguments(bool env) const;
	
	UnixProcess & set(const UnixProcess &);

	virtual bool start();

	void setEnvironment(const QStringList & e);
	void unsetEnvironment();
	QStringList getEnvironment() const;
	bool isEnvironmentSet() const;

	QString toCommandString() const;

public slots:
	bool tryTerminateGroup();
	bool killGroup();

private:
	bool envSet;
	QStringList env;
};

#endif /* __UNIXPROCESS_H */
