14535Seric # include "sendmail.h" 24535Seric 3*4636Seric static char SccsId[] = "@(#)daemon.c 3.3 10/27/81"; 44535Seric 54535Seric /* 64535Seric ** DAEMON.C -- routines to use when running as a daemon. 74535Seric */ 84535Seric /* 94535Seric ** GETREQUESTS -- open mail IPC port and get requests. 104535Seric ** 114535Seric ** Parameters: 124535Seric ** none. 134535Seric ** 144535Seric ** Returns: 154535Seric ** none. 164535Seric ** 174535Seric ** Side Effects: 184535Seric ** Waits until some interesting activity occurs. When 194535Seric ** it does, a child is created to process it, and the 204535Seric ** parent waits for completion. Return from this 214535Seric ** routine is always in the child. 224535Seric */ 234535Seric 244535Seric getrequests() 254535Seric { 26*4636Seric syserr("Daemon mode not yet implemented"); 27*4636Seric exit(EX_USAGE); 284631Seric 294631Seric for (;;) 304631Seric { 31*4636Seric register int pid; 32*4636Seric auto int st; 334631Seric 34*4636Seric /* 35*4636Seric ** Wait for a connection. 36*4636Seric */ 374631Seric 38*4636Seric /* MailPort = getconnection(); */ 394631Seric 40*4636Seric pid = fork(); 41*4636Seric if (pid < 0) 424631Seric { 43*4636Seric syserr("daemon: cannot fork"); 44*4636Seric sleep(10); 45*4636Seric continue; 464631Seric } 474631Seric 48*4636Seric if (pid == 0) 494631Seric { 50*4636Seric /* 51*4636Seric ** CHILD -- return to caller. 52*4636Seric ** Verify calling user id if possible here. 53*4636Seric */ 544631Seric 55*4636Seric initsys(); 56*4636Seric return; 574631Seric } 584631Seric 59*4636Seric /* 60*4636Seric ** PARENT -- wait for child to terminate. 61*4636Seric ** Perhaps we should allow concurrent processing? 62*4636Seric */ 634631Seric 64*4636Seric wait(&st); 654631Seric } 664631Seric } 67