Blame src/ProcWait.h

Packit 8f70b4
/*
Packit 8f70b4
 * lftp - file transfer program
Packit 8f70b4
 *
Packit 8f70b4
 * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net)
Packit 8f70b4
 *
Packit 8f70b4
 * This program is free software; you can redistribute it and/or modify
Packit 8f70b4
 * it under the terms of the GNU General Public License as published by
Packit 8f70b4
 * the Free Software Foundation; either version 3 of the License, or
Packit 8f70b4
 * (at your option) any later version.
Packit 8f70b4
 *
Packit 8f70b4
 * This program is distributed in the hope that it will be useful,
Packit 8f70b4
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 8f70b4
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 8f70b4
 * GNU General Public License for more details.
Packit 8f70b4
 *
Packit 8f70b4
 * You should have received a copy of the GNU General Public License
Packit 8f70b4
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit 8f70b4
 */
Packit 8f70b4
Packit 8f70b4
#ifndef PROCWAIT_H
Packit 8f70b4
#define PROCWAIT_H
Packit 8f70b4
Packit 8f70b4
#include <sys/types.h>
Packit 8f70b4
#include <signal.h>
Packit 8f70b4
#include "SMTask.h"
Packit 8f70b4
#include "xmap.h"
Packit 8f70b4
Packit 8f70b4
class ProcWait : public SMTask
Packit 8f70b4
{
Packit 8f70b4
public:
Packit 8f70b4
   enum	State
Packit 8f70b4
   {
Packit 8f70b4
      TERMINATED,
Packit 8f70b4
      RUNNING,
Packit 8f70b4
      ERROR
Packit 8f70b4
   };
Packit 8f70b4
Packit 8f70b4
protected:
Packit 8f70b4
   static xmap<ProcWait*> all_proc;
Packit 8f70b4
   static const xstring& proc_key(pid_t p); // make key for xmap
Packit 8f70b4
Packit 8f70b4
   const pid_t pid;
Packit 8f70b4
   State status;
Packit 8f70b4
   int	 term_info;
Packit 8f70b4
   int	 saved_errno;
Packit 8f70b4
   bool  auto_die;
Packit 8f70b4
Packit 8f70b4
   bool  handle_info(int info); // true if finished
Packit 8f70b4
Packit 8f70b4
   ~ProcWait();
Packit 8f70b4
Packit 8f70b4
public:
Packit 8f70b4
   int	 Do();
Packit 8f70b4
   State GetState() { return status; }
Packit 8f70b4
   int	 GetInfo() { return term_info; }
Packit 8f70b4
   int	 Kill(int sig=SIGTERM);
Packit 8f70b4
Packit 8f70b4
   void Auto() { auto_die=true; }
Packit 8f70b4
Packit 8f70b4
   ProcWait(pid_t p);
Packit 8f70b4
Packit 8f70b4
   static void Signal(bool yes);
Packit 8f70b4
Packit 8f70b4
   static void DeleteAll();
Packit 8f70b4
};
Packit 8f70b4
Packit 8f70b4
#endif /* PROCWAIT_H */