home *** CD-ROM | disk | FTP | other *** search
- /*======================================================================
- G E N E R R . C
- doc: Tue Jul 20 10:48:03 1993
- dlm: Tue Aug 17 09:55:01 1993
- (c) 1993 ant@bernina.ethz.ch
- uE-Info: 18 6 T 0 0 72 2 2 8 ofnI
- ======================================================================*/
-
- /*#define FOREGROUND /* Don't fork */
-
- #include <stdio.h>
- #include <syslog.h>
- #include <fcntl.h>
- #include <signal.h>
- #include <sys/ioctl.h>
- #ifndef TIOCNOTTY
- #include <termios.h>
- #endif
- #include "version.h"
- #include "patchlevel.h"
- #include "config.h"
- #include "common.h"
- #include "stderr.h"
-
- main(ac,av)
- int ac; char *av[];
- {
- int i;
-
- fprintf(stderr,"%s [%s%d]\n",av[0],VERSION,PATCHLEVEL);
- #ifdef NOSYSLOG_QUIRK
- fprintf(stderr,"\tMessages in file %s%s\n",_P_tmpdir,NOSYSLOG);
- #else
- fprintf(stderr,"\tMessages in syslog(3)\n");
- #endif
- #ifdef NOASYNCIO_QUIRK
- fprintf(stderr,"\tStderr redirection files in directory %s\n",
- _P_tmpdir);
- #else
- fprintf(stderr,"\tStderr ditto\n");
- #endif
- fprintf(stderr,"\tStdout on Console\n");
-
- OPENLOG(av[0]);
-
- #ifndef FOREGROUND
- if (fork() == 0) {
- #endif
- for (i = 0 ; i < 20; i++)
- (void) close(i);
- #ifdef O_NOCTTY
- i = open("/dev/console",O_WRONLY|O_NOCTTY);
- #else
- i = open("/dev/console",O_WRONLY);
- #endif
- (void) dup2(i,1);
- (void) dup2(i,2);
- printf("Stdout of %s [%s%d]\n",av[0],VERSION,PATCHLEVEL);
-
- #ifndef KEEPTTY_QUIRK
- i = open("/dev/tty",O_WRONLY);
- if (i >= 0) {
- (void) ioctl(i, TIOCNOTTY, (char *)NULL);
- (void) close(i);
- }
- #endif
- if (openStderr(av[0]) < 0) exit(1);
- #ifndef FOREGROUND
- if (fork() == 0) {
- signal(SIGIO,SIG_IGN);
- #endif
- SYSLOG(LOG_NOTICE,"syslog of %s [%s%d]",av[0],VERSION,PATCHLEVEL);
- fprintf(stderr,"Stderr of %s [%s%d]\n",av[0],VERSION,PATCHLEVEL);
- #ifndef FOREGROUND
- exit(0);
- }
- wait(NULL);
- #endif
- closeStderr();
- CLOSELOG();
- #ifndef FOREGROUND
- exit(0);
- }
- wait(NULL);
- #endif
- exit(0);
- }
-