[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] Pipes



> Er der nogen der har en idé til hvordan man åbner en pipe som man 
> både kan læse og skrive til?

Jeg mener at følgende vil gøre hvad du eftersøger:

int pipes[2];

if (pipe(pipes) == 0) {
  if (fork) {
    /* Jeg er parent - lav din læsen og skriven her - pipes[0] læser fra
       den anden process, pipes[1] skriver til den. Ispell dør når du
       laver close på pipen */
    close(pipes[0]);
    close(pipes[1]);
    }
  else
    {
    /* Jeg er child og skal lave arbejdet... */
    close(0);
    close(1);
    dup(pipes[0]);
    dup(pipes[1]);
    /* Først lukker jeg stdin og stdout, bagefter duplicater jeg pipen
       over i stedet for */
    exec("ispell");
    }
  }


Alt er taget fra hukommelsen så det virker sikkert ikke ;)

/Jesper

"Microsoft does have a Year 2000 problem. We're it"
(c) unknown       - Go Linux! http://www.linux.org/

 Jesper Monsted - RIPE: JM42 - sslug@sslug



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:08 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *