aboutsummaryrefslogtreecommitdiffstats
path: root/src/handerror.c
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2020-10-31 17:45:29 +0000
committerJoursoir <chat@joursoir.net>2020-10-31 17:45:29 +0000
commit64ef51a8ce6bc148ba493e350e2cac4cba470201 (patch)
tree4418c4133b16341975cfe4d29df8da6ce27abcff /src/handerror.c
parent38a3be4a3eeacec75a534fef6951b9484b4d7098 (diff)
downloadlock-password-64ef51a8ce6bc148ba493e350e2cac4cba470201.tar.gz
lock-password-64ef51a8ce6bc148ba493e350e2cac4cba470201.tar.bz2
lock-password-64ef51a8ce6bc148ba493e350e2cac4cba470201.zip
some features:
remake README.md for new code architecture; add help command; add man page;
Diffstat (limited to 'src/handerror.c')
-rw-r--r--src/handerror.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/handerror.c b/src/handerror.c
new file mode 100644
index 0000000..35e8f28
--- /dev/null
+++ b/src/handerror.c
@@ -0,0 +1,30 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+void callError(int num)
+{
+ fprintf(stderr, "lpass: Sorry, there was an error in the program [#%d]\n", num);
+ exit(3);
+}
+
+void printError(char *text)
+{
+ fprintf(stderr, "%s", text);
+ exit(4);
+}
+
+void easyFork(char *name, char *arguments[])
+{
+ int pid;
+ pid = fork();
+ if(pid == -1) callError(100);
+ if(pid == 0) { /* new process */
+ execvp(name, arguments);
+ perror(name);
+ exit(4);
+ }
+ wait(&pid);
+}
+