Пример #1
0
int child_process()
{
int i;
int status;
pid_t pid;
pid_t waitpid;
pid = fork();
  if(pid == -1)
    { fprintf(stderr,"[-]%s. Fork Failed!\n",strerror(errno) );
      exit(127);
    }
  else if (pid == 0)
    { vuln_start();
      
    }
      else {
       waitpid = wait(&status);
          if(waitpid == -1)
	   { fprintf(stderr,"[-] %s. Wait Failed! \n",strerror(errno));
	     exit(1);
	   }
	   else if(waitpid != pid)
	   abort();
	   else 
             {
	       if(WIFEXITED(status))
	          { printf("Child Terminated Normally. Exit Code = %d\n",WEXITSTATUS(status));
		    return WEXITSTATUS(status);
		  }
	       else if(WIFSIGNALED(status))
	          { printf("Child Terminated Abnormally. Exit Code = %d.(%s)\n",WTERMSIG(status),strsignal(WTERMSIG(status)));
		    return WTERMSIG(status);
	              if( COREDUMP(status) )
		        { printf(" Core Dumped,Core File Generated\n");
			}  
                  }
	       else{ fprintf(stderr,"[-] Child Stopped\n");
	            }
             }   
          }
	  
     return 1;
 }
Пример #2
0
/**
 *
 * dlinkGoodList is used to verify the "goodness" of a list.
 * All next and prev links are checked, to determine if the list is
 * fully connected in both directions, and properly terminated.
 * This routine is of interest to those who either
 * doubt the correctness of the list routines in this file,
 * suspect that they may be using these routines incorrectly,
 * or suspect that their lists are being trampled by some other routine.
 * It is, or course, a fairly expensive call.
 *
 * @param list a linked list
 * @return true if the list correctly structured
 */
bool
dlinkGoodList(DLinkList *list)
{
        DLinkNode *current = list->head;
        DLinkNode *last;

        if (current == NULLNODE)
        {
                if (list->tail == NULLNODE)
                        return true;
                else
                        COREDUMP();
        }

        if ( current->prev != NULLNODE )
                COREDUMP();

        last = current;
        current = current->next;

        while ( current != NULLNODE )
        {
                if ( current->prev != last )
                        COREDUMP();

                if ( last->up != list )
                        COREDUMP();

                last = current;
                current = current->next;
        }

        if ( last->up != list )
                COREDUMP();

        if ( last != list->tail )
                COREDUMP();

        return true;
}