summaryrefslogtreecommitdiffstats
path: root/maildrop/pipefds.h
blob: 1077114bd82af49d6bdd3bc4220668deff5d3420 (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
#ifndef	pipefds_h
#define	pipefds_h


/////////////////////////////////////////////////////////////////////////
//
//  Convenience class - automatically destroy pair of pipe handles.
//
/////////////////////////////////////////////////////////////////////////

#include	"config.h"
#include	<stdlib.h>
#if	HAVE_UNISTD_H
#include	<unistd.h>
#endif

class PipeFds {
public:
	int fds[2];

	PipeFds() { fds[0]= -1; fds[1]= -1; }
	int Pipe();
	void close0()
		{
			if (fds[0] >= 0)	close(fds[0]);
			fds[0]= -1;
		}
	void close1()
		{
			if (fds[1] >= 0)	close(fds[1]);
			fds[1]= -1;
		}
	~PipeFds();
} ;
#endif