-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
30 lines (26 loc) · 831 Bytes
/
Copy pathmain.cpp
File metadata and controls
30 lines (26 loc) · 831 Bytes
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
#include <QtCore/QCoreApplication>
#include <unistd.h>
#include <iostream>
#include "init.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
Init i;
switch(int pid = fork()) {
case -1:
std::cout << "Error attempting to fork to background. Exiting" << std::endl;
return -1;
break;
case 0:
setsid();
i.run();
break;
default:
std::cout << argv[0] << " Running in background ("<< pid << ")" << std::endl;
fclose(stdout);
fclose(stdin);
fclose(stderr);
break;
}
return a.exec();
}