Exemplo n.º 1
0
int main(int ac, char *av[])
{
	int	pid, todc[2], fromdc[2];	/* equipment	*/

	/*
	 * special case for -c option
	 */
	if ( ac > 1 && strcmp(av[1], "-c") == 0 ){
		compile_only();
		return 0;
	}

	/* make two pipes */

	if ( pipe(todc) == -1 || pipe(fromdc) == -1 )
		oops("pipe failed", 1);

	/* get a process for user interface */

	if ( (pid = fork()) == -1 )
		oops("cannot fork", 2);
	if ( pid == 0 )				/* child is dc	*/
		be_dc(todc, fromdc);
	else {
		be_bc(todc, fromdc);		/* parent is ui	*/
		wait(NULL);			/* wait for child */
	}
	return 0;
}
Exemplo n.º 2
0
int main(void) {
  int todc[2], fromdc[2];
  pipe(todc);
  pipe(fromdc);
  
  if (fork() == 0) {
    be_dc(todc, fromdc);
  }
  else {
    be_bc(todc, fromdc);
    wait(NULL);
  }
  return EXIT_SUCCESS;
}
Exemplo n.º 3
0
int main(){
    int pid,todc[2],fromdc[2];
    //make 2 pipes

    if(pipe(todc)==-1||pipe(fromdc)==-1){
        oops("pipe failed",1);
    }
    if((pid=fork())==-1){
        oops("fork failed",1);
    }
    if(pid==0){
        be_dc(todc,fromdc);
    }else{
        be_bc(todc,fromdc);
        wait(NULL);
    }
}
Exemplo n.º 4
0
int main( void )
{
  int pid, todc[2], fromdc[2];

  if( pipe( todc ) == -1 || pipe( fromdc ) == -1 ) {
    oops( "pipe failed", 1 );
  }

  if( ( pid = fork() ) == -1 ) {
    oops( "cannot fork", 2 );
  }

  if( pid == 0 ) {
    be_dc( todc, fromdc );
  } else {
    be_bc( todc, fromdc );
    wait( NULL );
  }

  return 0;
}
Exemplo n.º 5
0
int main(int argc, char *argv[])
{
    int pid, todc[2], fromdc[2];

    /* make tow pipes */

    if (pipe(todc) == -1 || pipe(fromdc) == -1)
        opps("pipe failed", 1);

    /* get a process for user interface */

    if ((pid = fork()) == -1)
        opps("Cannot fork", 2);
    if (pid == 0)               /* child dc */
        be_dc(todc, fromdc);
    else{
        be_bc(todc, fromdc);
        wait(NULL);
    }

    return 0;
}