VirtualBox

忽略:
時間撮記:
2009-10-20 下午05:48:40 (15 年 以前)
作者:
vboxsync
訊息:

re-apply r53640, r53642

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Runtime/r3/init.cpp

    r23892 r23919  
    4242# ifndef RT_OS_OS2
    4343#  include <pthread.h>
     44#  include <signal.h>
     45#  include <errno.h>
     46#  define IPRT_USE_SIG_CHILD_DUMMY
    4447# endif
    4548#endif
     
    204207}
    205208
     209
     210#ifdef IPRT_USE_SIG_CHILD_DUMMY
     211/**
     212 * Dummy SIGCHILD handler.
     213 *
     214 * Assigned on rtR3Init only when SIGCHILD handler is set SIGIGN or SIGDEF to
     215 * ensure waitpid works properly for the terminated processes.
     216 */
     217static void rtR3SigChildHandler(int iSignal)
     218{
     219    NOREF(iSignal);
     220}
     221#endif /* IPRT_USE_SIG_CHILD_DUMMY */
     222
     223
    206224/**
    207225 * rtR3Init worker.
     
    296314    atexit(rtR3ExitCallback);
    297315
     316#ifdef IPRT_USE_SIG_CHILD_DUMMY
     317    /*
     318     * SIGCHLD must not be ignored (that's default), otherwise posix compliant waitpid
     319     * implementations won't work right.
     320     */
     321    for (;;)
     322    {
     323        struct sigaction saOld;
     324        rc = sigaction(SIGCHLD, 0, &saOld);         AssertMsg(rc == 0, ("%d/%d\n", rc, errno));
     325        if (    rc != 0
     326            ||  (saOld.sa_flags & SA_SIGINFO)
     327            || (   saOld.sa_handler != SIG_IGN
     328                && saOld.sa_handler != SIG_DFL)
     329           )
     330            break;
     331
     332        /* Try install dummy handler. */
     333        struct sigaction saNew = saOld;
     334        saNew.sa_flags   = SA_NOCLDSTOP | SA_RESTART;
     335        saNew.sa_handler = rtR3SigChildHandler;
     336        rc = sigemptyset(&saNew.sa_mask);           AssertMsg(rc == 0, ("%d/%d\n", rc, errno));
     337        struct sigaction saOld2;
     338        rc = sigaction(SIGCHLD, &saNew, &saOld2);   AssertMsg(rc == 0, ("%d/%d\n", rc, errno));
     339        if (    rc != 0
     340            ||  (   saOld2.sa_handler == saOld.sa_handler
     341                 && !(saOld2.sa_flags & SA_SIGINFO))
     342           )
     343            break;
     344
     345        /* Race during dynamic load, restore and try again... */
     346        sigaction(SIGCHLD, &saOld2, NULL);
     347        RTThreadYield();
     348    }
     349#endif /* IPRT_USE_SIG_CHILD_DUMMY */
     350
    298351#ifdef IPRT_WITH_ALIGNMENT_CHECKS
    299352    /*
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette