VirtualBox

Ignore:
Timestamp:
Oct 7, 2010 10:15:26 AM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
66476
Message:

XPCOM: implement a shortcut PR_CreateProcessDetached which directly uses IPRT to daemonize the process. XPCOM only starts IPCD this way, and its own code didn't properly detach it, it remained a child of the client which triggered the IPCD start.

Location:
trunk/src/libs/xpcom18a4/nsprpub/pr/include
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/nsprpub/pr/include/md/_unixos.h

    r1 r32971  
    173173
    174174#if defined(DEBUG) && !defined(DARWIN) && !defined(NEXTSTEP)
    175 #if !defined(SOLARIS)   
     175#if !defined(SOLARIS)
    176176#include <string.h>  /* for memset() */
    177177#define _MD_INIT_STACK(ts,REDZONE)                                      \
     
    218218#endif  /* DEBUG */
    219219
    220 #if !defined(SOLARIS) 
     220#if !defined(SOLARIS)
    221221
    222222#define PR_SET_INTSOFF(newval)
     
    246246);
    247247
     248#ifdef VBOX
     249/* Create a new detached process (fork() + exec()) */
     250#define _MD_CREATE_PROCESS_DETACHED _MD_CreateUnixProcessDetached
     251extern PRStatus _MD_CreateUnixProcessDetached(
     252    const char *path,
     253    char *const *argv,
     254    char *const *envp,
     255    const struct PRProcessAttr *attr
     256);
     257#endif /* VBOX */
     258
    248259#define _MD_DETACH_PROCESS _MD_DetachUnixProcess
    249260extern PRStatus _MD_DetachUnixProcess(struct PRProcess *process);
     
    297308
    298309extern void             _MD_MakeNonblock(PRFileDesc *fd);
    299 #define _MD_MAKE_NONBLOCK                       _MD_MakeNonblock               
     310#define _MD_MAKE_NONBLOCK                       _MD_MakeNonblock
    300311
    301312/************************************************************************/
     
    401412#define _MD_SHUTDOWN    _MD_shutdown
    402413
    403 extern PRInt32          _MD_recv(PRFileDesc *fd, void *buf, PRInt32 amount, 
     414extern PRInt32          _MD_recv(PRFileDesc *fd, void *buf, PRInt32 amount,
    404415                               PRIntn flags, PRIntervalTime timeout);
    405416#define _MD_RECV        _MD_recv
  • trunk/src/libs/xpcom18a4/nsprpub/pr/include/private/primpl.h

    r11551 r32971  
    9191
    9292/*
    93 NSPR 2.0 must implement its function across a range of platforms 
     93NSPR 2.0 must implement its function across a range of platforms
    9494including: MAC, Windows/16, Windows/95, Windows/NT, and several
    95 variants of Unix. Each implementation shares common code as well 
     95variants of Unix. Each implementation shares common code as well
    9696as having platform dependent portions. This standard describes how
    9797the model dependent portions are to be implemented.
    9898
    99 In header file pr/include/primpl.h, each publicly declared 
     99In header file pr/include/primpl.h, each publicly declared
    100100platform dependent function is declared as:
    101101
     
    103103#define _PR_MD_FUNCTION _MD_FUNCTION
    104104
    105 In header file pr/include/md/<platform>/_<platform>.h, 
     105In header file pr/include/md/<platform>/_<platform>.h,
    106106each #define'd macro is redefined as one of:
    107107
     
    113113Where:
    114114
    115 <blanks> is no definition at all. In this case, the function is not implemented 
    116 and is never called for this platform. 
    117 For example: 
     115<blanks> is no definition at all. In this case, the function is not implemented
     116and is never called for this platform.
     117For example:
    118118#define _MD_INIT_CPUS()
    119119
    120 <expanded macro> is a C language macro expansion. 
    121 For example: 
     120<expanded macro> is a C language macro expansion.
     121For example:
    122122#define        _MD_CLEAN_THREAD(_thread) \
    123123    PR_BEGIN_MACRO \
     
    126126    PR_END_MACRO
    127127
    128 <osFunction> is some function implemented by the host operating system. 
    129 For example: 
     128<osFunction> is some function implemented by the host operating system.
     129For example:
    130130#define _MD_EXIT        exit
    131131
    132 <_MD_function> is the name of a function implemented for this platform in 
    133 pr/src/md/<platform>/<soruce>.c file. 
    134 For example: 
     132<_MD_function> is the name of a function implemented for this platform in
     133pr/src/md/<platform>/<soruce>.c file.
     134For example:
    135135#define        _MD_GETFILEINFO         _MD_GetFileInfo
    136136
     
    181181
    182182/*
    183  * bits defined for pthreads 'state' field 
     183 * bits defined for pthreads 'state' field
    184184 */
    185185#define PT_THREAD_DETACHED  0x01    /* thread can't be joined */
     
    207207#endif /* GC_LEAK_DETECTOR */
    208208
    209 /* 
     209/*
    210210** Possible values for thread's suspend field
    211211** Note that the first two can be the same as they are really mutually exclusive,
     
    247247#ifdef _PR_LOCAL_THREADS_ONLY
    248248
    249 #define        _PR_MD_SUSPEND_THREAD(thread)       
    250 #define        _PR_MD_RESUME_THREAD(thread)       
    251 #define        _PR_MD_SUSPEND_CPU(cpu)       
    252 #define        _PR_MD_RESUME_CPU(cpu)       
    253 #define        _PR_MD_BEGIN_SUSPEND_ALL()       
    254 #define        _PR_MD_END_SUSPEND_ALL()       
    255 #define        _PR_MD_BEGIN_RESUME_ALL()       
     249#define        _PR_MD_SUSPEND_THREAD(thread)
     250#define        _PR_MD_RESUME_THREAD(thread)
     251#define        _PR_MD_SUSPEND_CPU(cpu)
     252#define        _PR_MD_RESUME_CPU(cpu)
     253#define        _PR_MD_BEGIN_SUSPEND_ALL()
     254#define        _PR_MD_END_SUSPEND_ALL()
     255#define        _PR_MD_BEGIN_RESUME_ALL()
    256256#define        _PR_MD_END_RESUME_ALL()
    257257#define _PR_MD_INIT_ATTACHED_THREAD(thread) PR_FAILURE
     
    294294    PRThread *idle_thread;      /* user-level idle thread for this CPUThread */
    295295
    296     PRIntervalTime last_clock;  /* the last time we went into 
     296    PRIntervalTime last_clock;  /* the last time we went into
    297297                                 * _PR_ClockInterrupt() on this CPU
    298298                                 */
     
    317317#endif
    318318
    319 #ifdef _PR_LOCAL_THREADS_ONLY 
     319#ifdef _PR_LOCAL_THREADS_ONLY
    320320
    321321NSPR_API(struct _PRCPU *)              _pr_currentCPU;
     
    405405    PR_END_MACRO
    406406
    407 #ifdef _PR_LOCAL_THREADS_ONLY 
     407#ifdef _PR_LOCAL_THREADS_ONLY
    408408
    409409#define _PR_IS_NATIVE_THREAD(thread) 0
     
    435435
    436436#define _PR_ADD_SLEEPQ(_thread, _timeout) \
    437     _PR_AddSleepQ(_thread, _timeout);   
     437    _PR_AddSleepQ(_thread, _timeout);
    438438
    439439#define _PR_DEL_SLEEPQ(_thread, _propogate) \
    440     _PR_DelSleepQ(_thread, _propogate); 
     440    _PR_DelSleepQ(_thread, _propogate);
    441441
    442442#define _PR_ADD_JOINQ(_thread, _cpu) \
     
    470470    _PR_MD_LOCK(&(_cpu)->queue->runQLock );\
    471471    PR_END_MACRO
    472    
     472
    473473#define _PR_RUNQ_UNLOCK(_cpu) \
    474474    PR_BEGIN_MACRO \
     
    519519    PR_ASSERT((_thread)->queueCount == 0); \
    520520    (_thread)->queueCount = QUEUE_SLEEP; \
    521     _PR_AddSleepQ(_thread, _timeout); 
     521    _PR_AddSleepQ(_thread, _timeout);
    522522
    523523#define _PR_DEL_SLEEPQ(_thread, _propogate) \
    524524    PR_ASSERT((_thread)->queueCount == QUEUE_SLEEP);\
    525525    (_thread)->queueCount = 0; \
    526     _PR_DelSleepQ(_thread, _propogate); 
     526    _PR_DelSleepQ(_thread, _propogate);
    527527
    528528#define _PR_ADD_JOINQ(_thread, _cpu) \
     
    577577#define _PR_LOCK_UNLOCK(_lock) \
    578578    _PR_MD_UNLOCK(&(_lock)->ilock);
    579    
     579
    580580extern void _PR_UnblockLockWaiter(PRLock *lock);
    581581
     
    586586
    587587#define _PR_CVAR_LOCK(_cvar) \
    588     _PR_MD_LOCK(&(_cvar)->ilock); 
     588    _PR_MD_LOCK(&(_cvar)->ilock);
    589589#define _PR_CVAR_UNLOCK(_cvar) \
    590590    _PR_MD_UNLOCK(&(_cvar)->ilock);
     
    626626#define _PR_STACK_PRIMORDIAL    0x4    /* stack for primordial thread */
    627627
    628 /* 
     628/*
    629629** If the default stcksize from the client is zero, we need to pick a machine
    630630** dependent value.  This is only for standard user threads.  For custom threads,
     
    996996#define    _PR_MD_END_RESUME_ALL _MD_END_RESUME_ALL
    997997
    998 #if defined(IRIX) 
     998#if defined(IRIX)
    999999NSPR_API(void) _PR_IRIX_CHILD_PROCESS(void);
    10001000#endif        /* IRIX */
     
    10171017
    10181018extern PRStatus _PR_MD_CREATE_THREAD(
    1019                         PRThread *thread, 
    1020                         void (*start) (void *), 
    1021                         PRThreadPriority priority,                     
     1019                        PRThread *thread,
     1020                        void (*start) (void *),
     1021                        PRThreadPriority priority,
    10221022                        PRThreadScope scope,
    10231023                        PRThreadState state,
     
    11911191#define    _PR_MD_SHUTDOWN _MD_SHUTDOWN
    11921192
    1193 extern PRInt32 _PR_MD_RECV(PRFileDesc *fd, void *buf, PRInt32 amount, 
     1193extern PRInt32 _PR_MD_RECV(PRFileDesc *fd, void *buf, PRInt32 amount,
    11941194                               PRIntn flags, PRIntervalTime timeout);
    11951195#define    _PR_MD_RECV _MD_RECV
    11961196
    11971197extern PRInt32 _PR_MD_SEND(
    1198     PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, 
     1198    PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,
    11991199    PRIntervalTime timeout);
    12001200#define    _PR_MD_SEND _MD_SEND
    12011201
    1202 extern PRInt32 _PR_MD_ACCEPT_READ(PRFileDesc *sd, PRInt32 *newSock, 
     1202extern PRInt32 _PR_MD_ACCEPT_READ(PRFileDesc *sd, PRInt32 *newSock,
    12031203                                PRNetAddr **raddr, void *buf, PRInt32 amount,
    12041204                                PRIntervalTime timeout);
     
    12061206
    12071207#ifdef WIN32
    1208 extern PRInt32 _PR_MD_FAST_ACCEPT(PRFileDesc *fd, PRNetAddr *addr, 
     1208extern PRInt32 _PR_MD_FAST_ACCEPT(PRFileDesc *fd, PRNetAddr *addr,
    12091209                                PRUint32 *addrlen, PRIntervalTime timeout,
    12101210                                PRBool fast,
     
    12121212                                void *callbackArg);
    12131213
    1214 extern PRInt32 _PR_MD_FAST_ACCEPT_READ(PRFileDesc *sd, PRInt32 *newSock, 
     1214extern PRInt32 _PR_MD_FAST_ACCEPT_READ(PRFileDesc *sd, PRInt32 *newSock,
    12151215                                PRNetAddr **raddr, void *buf, PRInt32 amount,
    12161216                                PRIntervalTime timeout, PRBool fast,
     
    12231223
    12241224extern PRInt32 _PR_MD_SENDFILE(
    1225     PRFileDesc *sock, PRSendFileData *sfd, 
     1225    PRFileDesc *sock, PRSendFileData *sfd,
    12261226        PRInt32 flags, PRIntervalTime timeout);
    12271227#define _PR_MD_SENDFILE _MD_SENDFILE
     
    13011301        } else { \
    13021302                PR_SetError(PR_IO_TIMEOUT_ERROR, 0); \
    1303         }                                                       
    1304                
     1303        }
     1304
    13051305extern void *_PR_MD_GET_SP(PRThread *thread);
    13061306#define    _PR_MD_GET_SP _MD_GET_SP
     
    14541454    struct PRThread *owner;         /* current lock owner */
    14551455    PRCList waitQ;                  /* list of threads waiting for lock */
    1456     PRThreadPriority priority;      /* priority of lock */ 
     1456    PRThreadPriority priority;      /* priority of lock */
    14571457    PRThreadPriority boostPriority; /* boosted priority of lock owner */
    14581458    _MDLock ilock;                  /* Internal Lock to protect user-level fields */
     
    16621662    PRUint32 threadAllocatedOnStack;/* boolean */
    16631663
    1664     /* When an async IO is in progress and a second async IO cannot be 
     1664    /* When an async IO is in progress and a second async IO cannot be
    16651665     * initiated, the io_pending flag is set to true.  Some platforms will
    16661666     * not use the io_pending flag.  If the io_pending flag is true, then
     
    16691669    PRBool io_pending;
    16701670    PRInt32 io_fd;
    1671  
     1671
    16721672    /* If a timeout occurs or if an outstanding IO is interrupted and the
    1673      * OS doesn't support a real cancellation (NT or MAC), then the 
     1673     * OS doesn't support a real cancellation (NT or MAC), then the
    16741674     * io_suspended flag will be set to true.  The thread will be resumed
    16751675     * but may run into trouble issuing additional IOs until the io_pending
    1676      * flag can be cleared 
     1676     * flag can be cleared
    16771677     */
    16781678    PRBool io_suspended;
     
    17441744#endif
    17451745#if !defined(XP_UNIX)   /* BugZilla: 4090 */
    1746     PRBool  appendMode;                             
     1746    PRBool  appendMode;
    17471747#endif
    17481748    _MDFileDesc md;
     
    17621762
    17631763#ifdef MOZ_UNICODE
    1764 struct PRDirUTF16 { 
    1765     PRDirEntry d; 
    1766     _MDDirUTF16 md; 
    1767 }; 
     1764struct PRDirUTF16 {
     1765    PRDirEntry d;
     1766    _MDDirUTF16 md;
     1767};
    17681768#endif /* MOZ_UNICODE */
    17691769
     
    18961896#define    _PR_MD_CREATE_PROCESS _MD_CREATE_PROCESS
    18971897
     1898#ifdef _MD_CREATE_PROCESS_DETACHED
     1899# define _PR_MD_CREATE_PROCESS_DETACHED _MD_CREATE_PROCESS_DETACHED
     1900#endif
     1901
    18981902extern PRStatus _PR_MD_DETACH_PROCESS(PRProcess *process);
    18991903#define    _PR_MD_DETACH_PROCESS _MD_DETACH_PROCESS
     
    19031907
    19041908extern PRStatus _PR_MD_KILL_PROCESS(PRProcess *process);
    1905 #define    _PR_MD_KILL_PROCESS _MD_KILL_PROCESS       
     1909#define    _PR_MD_KILL_PROCESS _MD_KILL_PROCESS
    19061910
    19071911/* Current Time */
     
    20002004** Declare PRSharedMemory.
    20012005*/
    2002 struct PRSharedMemory 
     2006struct PRSharedMemory
    20032007{
    20042008    char        *ipcname; /* after conversion to native */
     
    20182022#define _PR_SHM_IDENT 0xdeadbad
    20192023};
    2020                                                      
    2021 extern PRSharedMemory * _MD_OpenSharedMemory( 
     2024
     2025extern PRSharedMemory * _MD_OpenSharedMemory(
    20222026    const char *name,
    20232027    PRSize      size,
     
    20392043#define _PR_MD_DELETE_SHARED_MEMORY  _MD_DeleteSharedMemory
    20402044
    2041 extern PRFileMap* _md_OpenAnonFileMap( 
     2045extern PRFileMap* _md_OpenAnonFileMap(
    20422046    const char *dirName,
    20432047    PRSize      size,
Note: See TracChangeset for help on using the changeset viewer.

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