Esempio n. 1
0
static inline void task_signalparent(FAR struct tcb_s *ctcb, int status)
{
#ifdef HAVE_GROUP_MEMBERS
  DEBUGASSERT(ctcb && ctcb->group);

  /* Keep things stationary throughout the following */

  sched_lock();

  /* Send SIGCHLD to all members of the parent's task group */

  task_sigchild(ctcb->group->tg_pgid, ctcb, status);
  sched_unlock();
#else
  FAR struct tcb_s *ptcb;

  /* Keep things stationary throughout the following */

  sched_lock();

  /* Get the TCB of the receiving, parent task.  We do this early to
   * handle multiple calls to task_signalparent.  ctcb->ppid is set to an
   * invalid value below and the following call will fail if we are
   * called again.
   */

  ptcb = sched_gettcb(ctcb->ppid);
  if (!ptcb)
    {
      /* The parent no longer exists... bail */

      sched_unlock();
      return;
    }

  /* Send SIGCHLD to all members of the parent's task group */

  task_sigchild(ptcb, ctcb, status);

  /* Forget who our parent was */

  ctcb->ppid = INVALID_PROCESS_ID;
  sched_unlock();
#endif
}
Esempio n. 2
0
void task_exithook(FAR _TCB *tcb, int status)
{
  /* If exit function(s) were registered, call them now before we do any un-
   * initialization.  NOTE:  In the case of task_delete(), the exit function
   * will *not* be called on the thread execution of the task being deleted!
   */

  task_atexit(tcb);

  /* Call any registered on_exit function(s) */

  task_onexit(tcb, status);

  /* Send SIGCHLD to the parent of the exit-ing task */

  task_sigchild(tcb, status);

  /* Wakeup any tasks waiting for this task to exit */

  task_exitwakeup(tcb, status);

  /* Flush all streams (File descriptors will be closed when
   * the TCB is deallocated).
   */

#if CONFIG_NFILE_STREAMS > 0
  (void)lib_flushall(tcb->streams);
#endif

  /* Discard any un-reaped child status (no zombies here!) */

#if defined(CONFIG_SCHED_HAVE_PARENT) && defined(CONFIG_SCHED_CHILD_STATUS)
  task_removechildren(tcb);
#endif

  /* Free all file-related resources now.  This gets called again
   * just be be certain when the TCB is delallocated. However, we
   * really need to close files as soon as possible while we still
   * have a functioning task.
   */

 (void)sched_releasefiles(tcb);
 
  /* Deallocate anything left in the TCB's queues */

#ifndef CONFIG_DISABLE_SIGNALS
  sig_cleanup(tcb); /* Deallocate Signal lists */
#endif
}