2 * Copyright (c) 2004 Apple Computer, Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
28 // child - track a single child process and its belongings
33 #include "securityserver.h"
38 // ChildManager - Singleton Child Manager class
43 // The singleton childManager.
44 static ChildManager childManager
;
49 // Return true in the child. Return false in the parent and set outChildPort to 0 if the child died prematuely. In this case outWaitStatus contains the result of a waitpid() on the child. if outChildPort is non 0 it's a send right to contact the child on.
50 bool forkChild(mach_port_t
&outChildPort
, int &outWaitStatus
);
52 // SigChild signal handler
53 void handleSignal(int signal
);
55 // Be notified a child just contacted us on our main server port telling us it's child port. Set childPort to 0 iff we don't wish it to be deallocated by our caller.
56 void registerChild(pid_t pid
, mach_port_t
&childPort
);
58 // Assumes mLock is not locked (called by Child's eraseFromMap() function).
59 void eraseChild(pid_t pid
);
61 // Assumes mLock is already locked (called by Child's insertInMap() function).
62 void insertChild(pid_t pid
, Child
*child
);
65 Child
*findChild(pid_t pid
);
67 void handleSigChild();
69 // Be notifed of a term or signal waitpid() status.
70 void waitStatusForPid(pid_t pid
, int status
);
73 typedef std::map
<pid_t
, Child
*> ChildMap
;