* Europagate, 1995
*
* $Log: monitor.c,v $
- * Revision 1.10 1995/05/18 12:03:09 adam
+ * Revision 1.11 1995/05/19 13:26:00 adam
+ * Bug fixes. Better command line options.
+ *
+ * Revision 1.10 1995/05/18 12:03:09 adam
* Bug fixes and minor improvements.
*
* Revision 1.9 1995/05/17 10:51:32 adam
fd_set set_r;
char command[128], *cp;
+ mknod (MONITOR_FIFO_C, S_IFIFO|0666, 0);
+ open (MONITOR_FIFO_C, O_RDONLY|O_NONBLOCK);
gip_m = gips_initialize (MONITOR_FIFO_S);
- r = gips_open (gip_m, MONITOR_FIFO_C);
+ r = gips_open (gip_m, MONITOR_FIFO_C, 0);
gip_m_fd = gip_infileno (gip_m);
- open (MONITOR_FIFO_S, O_WRONLY);
while (1)
{
}
str_queue_enq (ki->queue, "stop\n");
str_queue_enq (ki->queue, "\001");
- gw_log (GW_LOG_DEBUG, module, "Stopping %d", ki->id);
- deliver (argc, argv, ki->id, ki->queue, &ki->gip,
- &ki->pid, 1);
+ r = deliver (argc, argv, ki->id, ki->queue, &ki->gip,
+ &ki->pid, 1);
+ if (r != 1)
+ gw_log (GW_LOG_DEBUG, module,
+ "Stop not sent: %d", r);
str_queue_rm (&ki->queue);
break;
}
{
if (argv[argno][0] == '-')
{
+ if (argv[argno][1] == '-')
+ break;
switch (argv[argno][1])
{
+ case 'h':
case 'H':
- fprintf (stderr, "monitor [option..] [resource]\n");
- fprintf (stderr, "If no resource file is given");
+ fprintf (stderr, "monitor [options] [resourceFile]"
+ " -- [kernelOptions]\n");
+ fprintf (stderr, "If no resource file is specified");
fprintf (stderr, " default.res is used\n");
- fprintf (stderr, "Options are transferred to kernel\n");
+ fprintf (stderr, "Options:\n");
+ fprintf (stderr, " -l log Set Log file\n");
+ fprintf (stderr, " -d Enable debugging log\n");
+ fprintf (stderr, " -D Enable more debugging log\n");
+ fprintf (stderr, " -- Precedes kernel options\n");
+ fprintf (stderr, "Kernel options are transferred to kernel\n");
exit (1);
+ case 'l':
+ if (argv[argno][2])
+ gw_log_file (GW_LOG_ALL, argv[argno]+2);
+ else if (++argno < argc)
+ gw_log_file (GW_LOG_ALL, argv[argno]);
+ else
+ {
+ fprintf (stderr, "%s: missing log filename\n", *argv);
+ exit (1);
+ }
+ break;
case 'd':
gw_log_level (GW_LOG_ALL & ~RES_DEBUG);
break;
case 'D':
gw_log_level (GW_LOG_ALL);
break;
+ default:
+ fprintf (stderr, "%s: unknown option `%s'; use -H for help\n",
+ *argv, argv[argno]);
+ exit (1);
}
}
else
signal (SIGHUP, catch_hup);
signal (SIGTERM, catch_term);
signal (SIGINT, catch_int);
-#if 1
- gw_log_level (GW_LOG_ALL & ~RES_DEBUG);
- gw_log_file (GW_LOG_ALL, "monitor.log");
-#endif
- monitor_events (argc, argv);
+ monitor_events (argc-argno, argv+argno);
exit (0);
}