summaryrefslogtreecommitdiff
path: root/src/miav.cc
diff options
context:
space:
mode:
authordeva <deva>2005-05-22 15:49:22 +0000
committerdeva <deva>2005-05-22 15:49:22 +0000
commitb04122f3f7884de08eb5d59bb3fd2bff829f9039 (patch)
tree6898a061f4e10a6026faa1ffe4a7a319256dacdf /src/miav.cc
parentd74c7a00c417cffdc93a82efa2841e23d823bea6 (diff)
Added multithreaded encoding support.
Diffstat (limited to 'src/miav.cc')
-rw-r--r--src/miav.cc80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/miav.cc b/src/miav.cc
index ba30a17..c3f08fe 100644
--- a/src/miav.cc
+++ b/src/miav.cc
@@ -31,6 +31,9 @@
/*
* $Log$
+ * Revision 1.10 2005/05/22 15:49:22 deva
+ * Added multithreaded encoding support.
+ *
* Revision 1.9 2005/05/03 17:13:25 deva
* Fixed some missong Info object references.
*
@@ -92,6 +95,83 @@ int grab(int argc, char *argv[]) {
}
+#if 0
+/**
+ * Peters DAEMON code
+ */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+int rundaemon()
+{
+ int pipes[2];
+
+ int f;
+
+ pipe(pipes);
+
+ f = fork();
+ switch(f) {
+ case -1: // error
+ fprintf(stderr, "Error, could not fork()!\n");
+ exit(0);
+ break;
+ case 0: // child
+ return communicationCtl(pipes[0]);
+ break;
+ default: // parent
+ signal(SIGCHLD, reportAndExit);
+
+ return serialportCtl(pipes[1]);
+ break;
+ }
+
+ return 0;
+}
+
+void daemon() {
+ int f;
+ int fd;
+
+ chdir("/");
+ umask(0);
+
+ f = fork();
+ switch(f) {
+ case -1:
+ fprintf(stderr, "fork() error!\n");
+ return 0;
+ break;
+ case 0:
+ if( (fp = fopen("/tmp/termo.out", "w")) == NULL) {
+ fprintf(stderr, "Outfile open error!\n");
+ exit(0);
+ }
+ fd = open("/dev/null", O_NOCTTY | O_RDWR, 0666);
+ dup2(0, fd);
+ dup2(1, fd);
+ dup2(2, fd);
+ setsid();
+ signal (SIGTERM, SIG_IGN);
+ signal (SIGINT, SIG_IGN);
+ signal (SIGHUP, SIG_IGN);
+ serialfd = initSerialPort(INDEVICE);
+ if(setgid(NOBODY_GROUP) != 0) {fprintf(fp, "GRP ch ERR\n");return 1;}
+ if(setuid(NOBODY_USER) != 0) {fprintf(fp, "USER ch ERR\n");return 1;}
+
+ return rundaemon();
+ break;
+ default:
+ exit(0);
+ }
+ return 0;
+}
+/**
+ * End og Peters DAEMON code
+ */
+#endif
+
/**
* This function starts the MIaV server.
*/