32 lines
838 B
Diff
32 lines
838 B
Diff
Author: Michael Schmitz <schmitz@biophys.uni-duesseldorf.de>
|
|
Description: create pidfile in /run/mouseemu.pid
|
|
|
|
Note @q66: modified to use /run instead of /var/run
|
|
|
|
--- a/mouseemu.c
|
|
+++ b/mouseemu.c
|
|
@@ -755,6 +755,7 @@
|
|
|
|
struct sigaction sa;
|
|
sigset_t mask, oldmask;
|
|
+ FILE *pidfile;
|
|
|
|
/* SIGHUP and SIGALRM are only useful in the child */
|
|
memset(&sa, 0, sizeof(sa));
|
|
@@ -762,6 +763,15 @@
|
|
sigaction(SIGHUP, &sa, NULL);
|
|
sigaction(SIGALRM, &sa, NULL);
|
|
|
|
+ /* write PID file so the user can signal us for device rescans */
|
|
+ pidfile = fopen("/run/mouseemu.pid", "w");
|
|
+ if (!pidfile) {
|
|
+ perror("mouseemu: can't open /run/mouseemu.pid");
|
|
+ exit(1);
|
|
+ }
|
|
+ fprintf(pidfile, "%d\n", pid);
|
|
+ fclose(pidfile);
|
|
+
|
|
/*we start only after we received the first sigusr1 from child:*/
|
|
|
|
sigemptyset(&mask);
|