diff options
Diffstat (limited to 'src/miav.cc')
-rw-r--r-- | src/miav.cc | 80 |
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. */ |