Example #1
0
Frame::~Frame ()
{ 
  const size_t size = impl->children.size ();
  if (size != 0)
    {
#if 0
      std::ostringstream tmp;
      tmp << "Reparenting children of ";
      describe_frame (*this, tmp);
      for (Implementation::child_set::const_iterator i
             = impl->children.begin ();
           i != impl->children.end ();
           i++)
        {
          tmp << "\n" << "child" << ": ";
          describe_frame (**i, tmp);
        }
      daisy_warning (tmp.str ());
#endif
      reparent_children (parent ());
    }
}
Example #2
0
int terminate_process(process_t *proc, int return_value)
{
    if (!proc)
        return -1;

    reparent_children(proc);
    
    //printf("Killing process [%d]:%s \n", proc->pid, proc->name);
    if (proc == foreground_proc)
    {
        // Make parent of current process as foreground
        process_t *parent_proc = get_proc_from_pid(proc->ppid);
        if (parent_proc)
        {
            /* No point in making init the foreground proc. Make root
             * shell the BOSS
             */
            if ( parent_proc->pid == 1 )
            {
                parent_proc = get_proc_from_pid(2);
            }
            parent_proc->flags |= FOREGROUND_PROCESS;
            proc->flags &= ~FOREGROUND_PROCESS;
            foreground_proc = parent_proc;
        }
        else
        {
            /* Set it to root shell */
            foreground_proc = get_proc_from_pid(2);
        }
    }

    // Just deallocate resources but keep the process structure
    // and move process to TERMINATED QUEUE
    proc = pop_process_from_queue(proc);

    if (curr_running_proc == proc)
    {
        curr_running_proc =  NULL;
    }

    reclaim_process_resources(proc);

    kfree(delete_prev_stack);
    delete_prev_stack = proc->kernel_stack;
    proc->kernel_stack = NULL;

    add_process_to_queue(proc, PROCESS_TERMINATED_QUEUE);

    proc->exit_status = (return_value & 0xff);
    // If I am being waited upon by my parent, wake them up
    if (proc->flags & PAPA_WAITING)
    {
        process_t *parent_proc = get_proc_from_pid(proc->ppid);
        if (!parent_proc)
        {
            #ifdef LOG
                printf("Failed to get parent process during termination\n");
            #endif
            return -1;
        }
        switch_process_queue(parent_proc, PROCESS_RUNNABLE_QUEUE);
    }

    return 0;
}