summaryrefslogtreecommitdiff
path: root/lib/forkexec.h
blob: 9fdd98b7e1835f9153ea169318f44db4f4fa0baa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef NULLMAILER__FORK_EXEC__H
#define NULLMAILER__FORK_EXEC__H

#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include "mystring/mystring.h"
#include "autoclose.h"
#include "configio.h"

mystring program_path(const char* program);

#define REDIRECT_NONE -1
#define REDIRECT_NULL -2
#define REDIRECT_PIPE_FROM -3
#define REDIRECT_PIPE_TO -4

class fork_exec
{
 private:
  pid_t pid;
  const char* name;

 public:
  fork_exec(const char*);
  ~fork_exec();
  bool operator!() const;

  bool start(const char* args[], int redirn, int redirs[]);
  bool start(const char* program, int redirn, int redirs[]);
  bool wait();
  int wait_status();
  inline void kill(int sig) { ::kill(pid, sig); }
};

class queue_pipe : public fork_exec
{
  public:
  queue_pipe();
  int start();
};

#endif