-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
47 lines (39 loc) · 1.04 KB
/
main.cpp
File metadata and controls
47 lines (39 loc) · 1.04 KB
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
44
45
46
47
#include <iostream>
#include <unistd.h>
#include "notify.h"
#include "results.h"
using namespace std;
int main(int argc, char** argv)
{
int delay = 0;
int duration = 0;
if (argc != 4)
{
fprintf(stderr, "Usage: %s results_delay duration MOUNT\n", argv[0]);
exit(EXIT_FAILURE);
}
try
{
delay = atoi(argv[1]);
duration = atoi(argv[2]);
if (!delay || !duration)
{
fprintf(stderr, "Usage: %s results_delay duration MOUNT\n", argv[0]);
exit(EXIT_FAILURE);
}
results_init(delay); // Start of our results printer, is a thread
my_fanotify_init(argv[3]); // Initialise the fanotify watcher
my_fanotify_start(); // Start the fanotify watcher, is a thread
sleep(duration); // Let the threads do their thing for a while
my_fanotify_stop(); // Tell the watcher to stop
my_notify_destroy(); // Clean up the watcher
results_stop(); // Tell the results printer to stop
results_destroy(); // Clean up the results printer
}
catch (const std::bad_alloc &)
{
cerr << "Memory allocation failure" << endl;
return 1;
}
return 0;
}