14535Seric # include "sendmail.h" 24535Seric 3*4836Seric static char SccsId[] = "@(#)daemon.c 3.4 11/08/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 { 264636Seric syserr("Daemon mode not yet implemented"); 274636Seric exit(EX_USAGE); 284631Seric 294631Seric for (;;) 304631Seric { 314636Seric register int pid; 324636Seric auto int st; 334631Seric 344636Seric /* 354636Seric ** Wait for a connection. 364636Seric */ 374631Seric 384636Seric /* MailPort = getconnection(); */ 394631Seric 404636Seric pid = fork(); 414636Seric if (pid < 0) 424631Seric { 434636Seric syserr("daemon: cannot fork"); 444636Seric sleep(10); 454636Seric continue; 464631Seric } 474631Seric 484636Seric if (pid == 0) 494631Seric { 504636Seric /* 514636Seric ** CHILD -- return to caller. 524636Seric ** Verify calling user id if possible here. 534636Seric */ 544631Seric 554636Seric initsys(); 564636Seric return; 574631Seric } 584631Seric 594636Seric /* 604636Seric ** PARENT -- wait for child to terminate. 614636Seric ** Perhaps we should allow concurrent processing? 624636Seric */ 634631Seric 64*4836Seric (void) wait(&st); 654631Seric } 664631Seric } 67