Exemple #1
0
//Builds files in correct order. Returns -1 if any point fails. Returns 1 if 
//successful.
int run(){
	list_item* copy = first;

	list_item* save = copy;
	int r;	
	while(hasZero(copy))
	{
		int i = 0;
		Node** nodes_to_execute = malloc(sizeof(Node) * MAX_DEPENDS);
		while(copy != NULL)
		{
			Node nd = *((Node *)copy->item);
			if(nd.numTargetDep == 0){
				((Node*)copy->item)->numTargetDep = -10; //has zero, is not clean
				//nodes_to_execute[i] = &nd;
				nodes_to_execute[i] = ((Node*)copy->item);
				i++;
			}
			copy = copy->next;
		}  
		r = forkExec(nodes_to_execute,i);
		free(nodes_to_execute);
		copy = save;
	}
	return r;
}
Exemple #2
0
void
commxForkExec(const char *cmd, char *ptyslave)
{
    char *s;
    s = malloc(strlen(cmd) + strlen(ptyslave)+1);
    if (strcmp("/dev/", ptyslave) == 0 )
       ptyslave += 5;
    sprintf(s, cmd, ptyslave);
    forkExec(s);
}
Exemple #3
0
void
commxForkExec(const char *cmd, char c10, char c01)
{
    char c[16];
    char *s;

    strcpy(c, "tty");
    c[3] = c10; c[4] = c01; c[5] = 0;
    s = malloc(strlen(cmd) + strlen(c)+1);
    sprintf(s, cmd, c); /*'%s' -> 'p1' or sth*/
    forkExec(s);
}
Exemple #4
0
int main(int argc, char *argv[])
{
    char test[100];
    unsigned int task=0;
    File pp[2];
    int n;
    while(1)
    {
      if(!task)
      {
          printf("# >:");
          n=readLine(test,100);
          if(n>0)
          {  
              //printf("readLine: %s\n",test);
              if(strcmp(test,"exit")==0)
              {
                  syssleep(100);
                  return 0;
              }
              
              task=forkExec(test,pp);
              if(task==0) 
                  printf("FILE NOT FOUND\n");
          }
      }
      if(task)
      {
          n=readFile(pp[0],test,100);
          if(n>0)
          {
              test[n]=0;
              printf(test);
          }
          if(n==-1)
          {
              task=0;
              closeFile(pp[1]);
          }
          n=get(test,100);
          if(n>0)
          {
              if(findchar(test,3,0)>=0)
                  kill(task);
              writeFile(pp[1],test,n);
          }
      }
      syssleep(100);
    }
    
}