[BACK]Return to popen.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mail

Diff for /src/usr.bin/mail/popen.c between version 1.14 and 1.15

version 1.14, 1997/11/14 00:23:54 version 1.15, 1998/02/15 21:20:02
Line 66 
Line 66 
         int status;          int status;
         struct child *link;          struct child *link;
 };  };
 static struct child *child;  static struct child *child, *child_freelist = NULL;
 static struct child *findchild __P((int));  static struct child *findchild __P((int, int));
 static void delchild __P((struct child *));  static void delchild __P((struct child *));
 static int file_pid __P((FILE *));  static int file_pid __P((FILE *));
 static int handle_spool_locks __P((int));  static int handle_spool_locks __P((int));
Line 311 
Line 311 
 }  }
   
 static struct child *  static struct child *
 findchild(pid)  findchild(pid, dont_alloc)
         int pid;          int pid;
           int dont_alloc;
 {  {
         struct child **cpp;          struct child **cpp;
   
Line 320 
Line 321 
              cpp = &(*cpp)->link)               cpp = &(*cpp)->link)
                         ;                          ;
         if (*cpp == NULL) {          if (*cpp == NULL) {
                 *cpp = (struct child *)malloc(sizeof(struct child));                  if (dont_alloc)
                           return(NULL);
                   if (child_freelist) {
                           *cpp = child_freelist;
                           child_freelist = (*cpp)->link;
                   } else
                           *cpp = (struct child *)malloc(sizeof(struct child));
                 (*cpp)->pid = pid;                  (*cpp)->pid = pid;
                 (*cpp)->done = (*cpp)->free = 0;                  (*cpp)->done = (*cpp)->free = 0;
                 (*cpp)->link = NULL;                  (*cpp)->link = NULL;
Line 337 
Line 344 
         for (cpp = &child; *cpp != cp; cpp = &(*cpp)->link)          for (cpp = &child; *cpp != cp; cpp = &(*cpp)->link)
                 ;                  ;
         *cpp = cp->link;          *cpp = cp->link;
         (void)free(cp);          cp->link = child_freelist;
           child_freelist = cp;
 }  }
   
 void  void
Line 351 
Line 359 
   
         while ((pid =          while ((pid =
             waitpid((pid_t)-1, &status, WNOHANG)) > 0) {              waitpid((pid_t)-1, &status, WNOHANG)) > 0) {
                 cp = findchild(pid);                  cp = findchild(pid, 1);
                   if (!cp)
                           continue;
                 if (cp->free)                  if (cp->free)
                         delchild(cp);                          delchild(cp);
                 else {                  else {
Line 371 
Line 381 
 wait_child(pid)  wait_child(pid)
         int pid;          int pid;
 {  {
         struct child *cp = findchild(pid);          struct child *cp = findchild(pid, 0);
         sigset_t nset, oset;          sigset_t nset, oset;
   
         sigemptyset(&nset);          sigemptyset(&nset);
Line 393 
Line 403 
 free_child(pid)  free_child(pid)
         int pid;          int pid;
 {  {
         struct child *cp = findchild(pid);          struct child *cp = findchild(pid, 0);
         sigset_t nset, oset;          sigset_t nset, oset;
   
         sigemptyset(&nset);          sigemptyset(&nset);

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15