[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] Hjärn-släpp ??



"Joachim Holst (QCS)" wrote:
> main()
> {
>   int fd[2];

    int Pid=pipe(fd);

>   if( Pid== -1){ /* Create two file descriptors    */
>     printf("Couldn't create pipe.\n");
>     exit(0);
>   }

 if (Pid == 0)
   {                   // Child
     cout << "Child Process\n";
>   Class1 c1(fd);
>   c1.Write(fd[1]);
   }
else
  {                    // Parent
     cout << "Parent Process\n";
>   Class2 c2(fd);
>   c2.Read(fd[0]);
Her burde der vist ventes på at child processen er færdig før
at parent processen fortsætter og afsluttes. Ellers kan du risikere
at parent processen afsluttes før child processen er færdig.
> }

Så burde child processen oprette klassen c1, og skrive data til
pipe'en, mens parent opretter class c2 og modtager data med den.

I dit eksempel oprettes klasserne i både child og parent processerne.

-- 
	Sometimes it's better to light a       Carsten Svaneborg
      flamethrower than curse the darkness.      sslug@sslug
	-- (Terry Pratchett, Men At Arms)    Fight Bill - use Linux


 
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] *