aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authortoni <toni@devlap.local>2014-12-23 04:09:30 +0100
committertoni <toni@devlap.local>2014-12-23 21:21:53 +0100
commit580c7a2b483465310164d0928087244ea15d111b (patch)
tree7802934bf520848741f87a4d157a9312a555682a /main.c
parent2bb3dfdc0138a924b88a8a8529b4c01b43ae1add (diff)
working ui .. (testing)
Diffstat (limited to 'main.c')
-rw-r--r--main.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/main.c b/main.c
index a2ce646..a1fd090 100644
--- a/main.c
+++ b/main.c
@@ -1,12 +1,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
+#include <string.h>
#include <unistd.h>
#include <errno.h>
-#include <sys/wait.h>
#include <sys/stat.h>
-#include <sys/types.h>
-#include <semaphore.h>
#include <fcntl.h>
#include "ui_ani.h"
@@ -62,8 +60,8 @@ check_fifo(char *fifo_path)
int main(int argc, char **argv)
{
- pid_t child;
- int status, ffd;
+ int ffd;
+ size_t plen;
if (argc != 2) {
usage(argv[0]);
@@ -73,22 +71,25 @@ int main(int argc, char **argv)
if (check_fifo(argv[1]) == false) {
exit(EXIT_FAILURE);
}
- if ((ffd = open(argv[1], O_NONBLOCK)) < 0) {
+ if ((ffd = open(argv[1], O_NONBLOCK | O_RDWR)) < 0) {
perror("open");
exit(EXIT_FAILURE);
}
-
- if ((child = vfork()) == 0) {
- if (setsid() == (pid_t)-1) {
- perror("setsid");
- exit (EXIT_FAILURE);
+ do_ui();
+ if (passwd != NULL) {
+ plen = strlen(passwd);
+ printf("Sending your password to the FIFO ..\n");
+ if (write(ffd, (const void *)passwd, plen) != plen) {
+ perror("write");
+ } else {
+ printf("Ok.\n");
}
- do_ui();
- } if (child > 0) {
- wait(&status);
- }else {
- return (EXIT_FAILURE);
+ memset(passwd, '\0', plen);
+ plen = 0;
+ free(passwd);
}
+
+ close(ffd);
return (EXIT_SUCCESS);
}