On Jan 8, 2008 8:40 AM, Lorenzo Fiorini <[EMAIL PROTECTED]> wrote:

> I need to start several instances of the same Harbour app and I'd like
> to create an html "console" interface to see which are running.

Googling I've found a way to dot it.

Is this safe?

Comments from C gurus?

best regards,
Lorenzo

#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdio.h>

static int runit( const char * pFile )
{
   pid_t pid;

   switch( pid = fork () )
   {
      case -1:
         perror( "fork()");
         break;
      case 0:
         execlp( pFile, pFile, NULL );
         break;
      default:
         return(pid);
         if( waitpid( pid, NULL, 0 ) != pid )
            perror( "waitpid()" );
         break;
   }

}

int main(int argc, char** argv, char** env)
{
   int pid;

   pid = runit( argv[1] );

   printf( "pid %d", pid ); fflush(0);

   return(0);
}
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to