summaryrefslogtreecommitdiff
path: root/example.c
diff options
context:
space:
mode:
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2017-08-16 20:48:34 -0400
committerAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2017-08-16 20:48:34 -0400
commit7cf5bfe38b8345b2466d3ef7ba7d06040dc57e9d (patch)
tree4e90970f20f56d1082e8b69f1d05683fa659ff95 /example.c
parentcf89b3457feaa7f7695fc992d25473f773423008 (diff)
downloadinhibit-screensaver-master.tar.xz
inhibit-screensaver-master.zip
Improve C example.HEADmaster
Diffstat (limited to 'example.c')
-rw-r--r--example.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/example.c b/example.c
index b822312..2eeac2d 100644
--- a/example.c
+++ b/example.c
@@ -1,3 +1,4 @@
+#define _DEFAULT_SOURCE
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
@@ -22,11 +23,14 @@ int main() {
// works even if process dies!
kill(getpid(), SIGKILL);
+
+ // otherwise, release the inhibition:
+ close(pipefd[1]);
} else {
close(pipefd[1]);
- close(0);
dup2(pipefd[0], 0);
execl("./inhibit-screensaver", "./inhibit-screensaver", "c-inhibitor-example", "testing", (char *)NULL);
+ perror("exec inhibit-screensaver");
exit(1);
}
}