mirror of
https://github.com/MatMoul/g810-led.git
synced 2024-12-23 01:06:11 +00:00
fork two time, daemon unit
This commit is contained in:
parent
21fc1663ba
commit
f8ea392738
@ -1,6 +1,6 @@
|
|||||||
p sample_profiles/all_blue
|
p /etc/g810-led/sample_profiles/all_blue
|
||||||
w 1000
|
w 1000
|
||||||
p sample_profiles/all_green
|
p /etc/g810-led/sample_profiles/all_green
|
||||||
w 1000
|
w 1000
|
||||||
p sample_profiles/all_red
|
p /etc/g810-led/sample_profiles/all_red
|
||||||
w 1000
|
w 1000
|
||||||
|
@ -17,16 +17,35 @@ namespace daemonizer {
|
|||||||
|
|
||||||
void start(char *arg0, std::string scenarioFile) {
|
void start(char *arg0, std::string scenarioFile) {
|
||||||
pid_t pid, sid;
|
pid_t pid, sid;
|
||||||
|
|
||||||
|
pid = fork();
|
||||||
|
if (pid < 0) exit(EXIT_FAILURE);
|
||||||
|
if (pid > 0) exit(EXIT_SUCCESS);
|
||||||
|
sid = setsid();
|
||||||
|
if (sid < 0) exit(EXIT_FAILURE);
|
||||||
|
signal(SIGCHLD,SIG_IGN); /* ignore child */
|
||||||
|
signal(SIGHUP,SIG_IGN); /* ignore child */
|
||||||
|
|
||||||
|
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (pid < 0) exit(EXIT_FAILURE);
|
if (pid < 0) exit(EXIT_FAILURE);
|
||||||
if (pid > 0) exit(EXIT_SUCCESS);
|
if (pid > 0) exit(EXIT_SUCCESS);
|
||||||
umask(0);
|
umask(0);
|
||||||
sid = setsid();
|
if (chdir("/") < 0) exit(EXIT_FAILURE);
|
||||||
if (sid < 0) exit(EXIT_FAILURE);
|
|
||||||
|
|
||||||
//signal(SIGINT, stop);
|
|
||||||
std::cout<<getpid()<<std::endl;
|
std::cout<<getpid()<<std::endl;
|
||||||
|
|
||||||
|
close(STDIN_FILENO);
|
||||||
|
close(STDOUT_FILENO);
|
||||||
|
close(STDERR_FILENO);
|
||||||
|
|
||||||
|
signal(SIGCHLD,SIG_IGN); /* ignore child */
|
||||||
|
signal(SIGHUP,SIG_IGN); /* ignore child */
|
||||||
|
signal(SIGTSTP,SIG_IGN); /* ignore tty signals */
|
||||||
|
signal(SIGTTOU,SIG_IGN);
|
||||||
|
signal(SIGTTIN,SIG_IGN);
|
||||||
|
//signal(SIGINT, stop);
|
||||||
|
|
||||||
LedKeyboard kbd;
|
LedKeyboard kbd;
|
||||||
kbd.open();
|
kbd.open();
|
||||||
while(true){
|
while(true){
|
||||||
|
@ -2,10 +2,11 @@
|
|||||||
Description=Logitech G810 Led Scenarios
|
Description=Logitech G810 Led Scenarios
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
#ExecStart=/usr/bin/g810-led --daemon /etc/g810-led/scenario
|
ExecStartPre=/usr/bin/cp /etc/g810-led/scenario /tmp/g810-led-scenario
|
||||||
#ExecSop=kill -2 pid
|
ExecStartPre=/usr/bin/chmod 666 /tmp/g810-led-scenario
|
||||||
#Type=oneshot
|
ExecStart=/usr/bin/g810-led --daemon /tmp/g810-led-scenario
|
||||||
#RemainAfterExit=yes
|
ExecStopPost=/usr/bin/rm /tmp/g810-led-scenario
|
||||||
|
Type=forking
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
Loading…
Reference in New Issue
Block a user