Pipes und Buffer size



  • Hallo zusammen,

    ich benutze fork - pipe - execlp damit mein Prgramm mit einem anderen Programm kommuniziert. Das klappt soweit so gut. Manchmal muss mein Programm an das andere Programm 5000 Kommandos senmden. Die Kommandos sind:

    char command_burst[1024];
    

    Das Problem ist das nicht alle Kommandos gesendet werden. Es hört so bei 2400 Kommandos auf. Ich habe herum gegoogelt aber keine konkrete Lösüng gefunden. Bedeutet das nun das pipes für diese Geschichte nicht geeignet ist? Würde hier

    mkfifo
    

    weiterhelfen? was kann man sonst noch machen?

    Danke + Gruss,
    Haksi



  • more code



  • ok hier mal eine vereinfachte Version:

    ...
        int childin[2]; //child stdin pipe
        int childout[2]; //child stdout
        pid_t pid;
    
      if ( pipe( childin ) != 0 ){
        return False;
      }
      if ( pipe( childout ) != 0 ){
        return False;
      }
    
      pid = fork;
    ...
    
      if (pid == 0){
        //child
        dup2( childin[0], STDIN_FILENO )
        dup2( childout[1], STDOUT_FILENO  );
         //The cild process dont need read write
         //close all pipes
         close( childin[0] );
         close( childin[1] );
         close( childout[0] );
         close( childout[1] );
         execlp( "./burstsender", "./burstsender", NULL );
         ...
    
      } // End child
      else if(pid > 0){
         // Parent sender
         close( childin[0] );
         close( childout[1] );
         readfd = fdopen (childout[0], "r");
         writefd = fdopen (childin[1], "w");
         ...
    
         while(seq < packets){
           fprintf(writefd,"%s %d\n",burstcommand,seq);
           fflush(writefd);
           seq++;
         }
    
      }
    

Anmelden zum Antworten