/***************************************************************************
                Process functions
                -----------------------------------------
    begin      : 2013/06/21
	copyright  : (C) 2005 Solbox Inc.
    author     : Dev 1 Team
    email      : dev1@solbox.com
    version    : 3.2.0

    CopyRight(C) 2005 Solbox Inc. All Rights reserved.
    Redistribution and use in source and binary forms, with or with out
    modification, are not permitted in outside of Solbox Inc.
*****************************************************************************/

#ifndef __PROCESS_H__
#define __PROCESS_H__

#include <errno.h>
#define _WITH_DPRINTF
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <iostream>

#include "Signal_handle.h"
#include "ProcessRename.h"

using namespace std;

class CProcess {

public:
	static bool Daemon();
	static bool IS_DAEMON;
	static bool IsCurrentProcessRun(const char* pname);
	static bool IsProcessRun(const char* pname);

public:
	CProcess();
	virtual ~CProcess();

	virtual pid_t Launcher(const sig_atomic_t *sighandle) = 0;

	inline pid_t Getpid() { return m_pid; }
	inline bool Is_launched(){ return m_launched;  }

protected:
	// return
	//  0> : error
	//  0  : child process
	//  0< : parent process	
	pid_t Fork();

	void SetThreadSignal(int signum);
	void UnSetThreadSignal(int signum);
	
	pid_t	m_pid;
	bool	m_launched;
};


#endif // __PROCESS_H__
