summaryrefslogtreecommitdiffstats
path: root/maildrop/alarmsleep.C
blob: 610258e29163116aa74ea2afcf346270f0e2abe1 (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
#include	"config.h"
#include	<signal.h>
#include	"alarmsleep.h"


AlarmSleep::AlarmSleep(unsigned nseconds) : flag(0)
{
	sigset_t ss;

	sigemptyset(&ss);

	Set(nseconds);
	do
	{
		sigsuspend(&ss);
	} while (!flag);
	Cancel();
}

AlarmSleep::~AlarmSleep()
{
}

void AlarmSleep::handler()
{
	flag=1;
	Set(5);	// A possibility of a race condition - try again.
}