From: Mike Barsalou Date: 2009-09-10T08:05:09+09:00 Subject: Re: Duplicate this code in C On Sep 9, 5:08 am, Reid Thompson wrote: > On Wed, 2009-09-09 at 15:35 +0900, barjunk wrote: > > Is there a way to duplicate this code using C? > > >http://pastie.org/610698 > > > The goal is to launch multiple ruby processes from a C program. > > > Mike B. > > fromhttp://www.gidforums.com/t-11552.html > > mod to meet needs....google for more info... > > #include > #include > #include > #include > #include > int main() > { >     int i; >     pid_t cpid; >     pid_t child_pid; >     cpid = fork(); > >     switch (cpid) { >         case -1: printf("Fork failed; cpid == -1\n"); >                  break; > >         case 0: child_pid = getpid(); >                 for (i = 0; i < 10; i++) { >                     printf("%d: this is the child, pid = %d\n", i, child_pid); >                     sleep(1); >                 } >                 exit(0); > >         default: printf("This is the parent: waiting for %d to finish\n", cpid); >                  waitpid(cpid, NULL, 0); >                  printf("Ttttthat's all, folks\n"); >     } >     return 0; > > } > > Thanks for this. I should have been more specific and say that I was trying to write ruby code in C to then launch the forks....so I really mean to duplicate the ruby code to be ruby code ...in C.... Kaspar, Passenger does it, but using ruby. Mongrel doesn't install yet in 1.9, although I need to still go through the online code...I'm going to guess they do it in ruby as well. Any chance you could point me to actual code that does this? I looked at eventmachine too, but I'm not good enough to figure out what I need, which is kinda why I'm here. Again, thanks for any tips. Mike B.