Ejemplo n.º 1
0
int run_init_svc(char *cinit_svc)
{
   pid_t pid;

   /*
    * leave cinit alone 
    */
   pid = fork();

   if(pid == -1) {              /* err */
      print_errno(MSG_ERR_FORK);
      return 0;
   } else if(pid == 0) {        /* child */
      cinit_ipc_sclose();
      set_signals(ACT_CLIENT);

      if(!cinit_ipc_logon())
         _exit(1);

      /*
       * FIXME: open stderr, stdin, stdout to files / syslog / logable ?
       * IMPLEMENT PER SERVICE! 
       */

      run_svc(cinit_svc);

      _exit(0);                 /* nobody cares about us, so exit successfully
                                 * anyway */
   }
   /*
    * parent exits, we don't care about our children 
    */
   return 1;
}
Ejemplo n.º 2
0
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  if (argc != 2)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("usage: pingpong <string>\n")),
                       -1);

  ACE_LOG_MSG->open (argv[0]);

  string_name = argv[1];

  ACE_HANDLE handles[2];

  //FUZZ: disable check_for_lack_ACE_OS
  // Create a pipe and initialize the handles.
  ACE_Pipe pipe (handles);
  //FUZZ: enable check_for_lack_ACE_OS

#if defined (ACE_WIN32) || defined (CHORUS)
  if (ACE_Thread::spawn (ACE_THR_FUNC (worker),
                         (void *) handles[0],
                         THR_DETACHED) == -1
      || ACE_Thread::spawn (ACE_THR_FUNC (worker),
                            (void *) handles[1],
                            THR_DETACHED) == -1)
      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT ("%p\n%a"),
                  ACE_TEXT ("spawn"),
                  1));
  barrier.wait ();
#else
  pid_t pid = ACE_OS::fork (argv[0]);

  if (pid == -1)
    ACE_ERROR ((LM_ERROR,
                ACE_TEXT ("%p\n%a"),
                ACE_TEXT ("fork"),
                1));
  run_svc (handles[pid == 0]);

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("(%P|%t) %n: shutting down tester\n")));
#endif /* ACE_WIN32 */

  if (pipe.close () == -1)
    ACE_ERROR ((LM_ERROR,
                ACE_TEXT ("%p\n"),
                ACE_TEXT ("close")));
  return 0;
}
Ejemplo n.º 3
0
static void *
worker (void *arg)
{
  ACE_HANDLE handle = (ACE_HANDLE) arg;

  run_svc (handle);

  // Wait for the threads to exit.
  barrier.wait ();

  ACE_DEBUG ((LM_DEBUG,
              "(%P|%t) %n: shutting down tester\n"));
  return 0;
}
Ejemplo n.º 4
0
int
main (int argc, char *argv[])
{
  ACE_LOG_MSG->open (argv[0]);

  if (argc != 2)
    ACE_ERROR ((LM_ERROR,
                "usage: %n string\n%a",
                1));

  string_name = argv[1];

  ACE_HANDLE handles[2];

  // Create a pipe and initialize the handles.
  ACE_Pipe pipe (handles);

#if defined (ACE_WIN32) || defined (CHORUS)
  if (ACE_Thread::spawn (ACE_THR_FUNC (worker),
			 (void *) handles[0],
			 THR_DETACHED) == -1
      || ACE_Thread::spawn (ACE_THR_FUNC (worker),
			    (void *) handles[1],
			    THR_DETACHED) == -1)
      ACE_ERROR ((LM_ERROR,
                  "%p\n%a",
                  "spawn",
                  1));
  barrier.wait ();
#else
  pid_t pid = ACE_OS::fork (argv[0]);

  if (pid == -1)
    ACE_ERROR ((LM_ERROR,
                "%p\n%a",
                "fork",
                1));
  run_svc (handles[pid == 0]);

  ACE_DEBUG ((LM_DEBUG,
              "(%P|%t) %n: shutting down tester\n"));
#endif /* ACE_WIN32 */

  if (pipe.close () == -1)
    ACE_ERROR ((LM_ERROR,
                "%p\n",
                "close"));
  return 0;
}