/* Main SMTP Daemon */
/* */
/********************************************************/
+#include <errno.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include <unistd.h>
#include "subrou.h"
static void task(u_int iteration)
{
+#define OPEP "maild.c:task"
+char *emlrec;
+char *argv[10];
pid_t *pidlst;
int phase;
_Bool proceed;
+emlrec=rou_apppath("/usr/bin/emlrec");
+argv[0]=(char *)0;
pidlst=(pid_t *)calloc(iteration,sizeof(pid_t));
phase=0;
proceed=true;
switch (phase) {
case 0 : //looping forever email receiving processes
for (int i=0;i<iteration;i++) {
- int attend;
-
if (pidlst[i]!=(pid_t)0) {
if (prc_checkprocess(pidlst[i])==true)
continue;
}
- attend=(random()%10)+10;
switch (pidlst[i]=fork()) {
case -1 : //trouble trouble?
pidlst[i]=(pid_t)0;
break;
case 0 :
- (void) rec_getemail(attend);
- (void) exit(1);
+ (void) rou_alert(0,"Should execv \"%s\"",emlrec);
+ if (execv(emlrec,argv)<0) {
+ (void) rou_alert(0,"%s, Unable to exec command <%s> "
+ "(error=<%s>, system trouble?)",
+ OPEP,emlrec,strerror(errno));
+ (void) sleep(2); //to avoid avalanche
+ }
+ (void) exit(1); //reached only if trouble
break;
default :
break;
phase++;
}
(void) free(pidlst);
+#undef OPEP
}
/*
\f
//version definition
#define VERSION "0.2"
-#define RELEASE "1"
+#define RELEASE "2"
//Public variables
PUBLIC int debug=0; //debug level
/********************************************************/
void rou_valert(const int dlevel,const char *fmt,va_list ap)
-#define DEBMAX 80
+#define DEBMAX 120
{
if (debug>=dlevel)