Loading...
--- Libc/Libc-763.13/sys/posix_spawn.c
+++ Libc/Libc-498/sys/posix_spawn.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2008 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
@@ -27,7 +27,6 @@
#include <sys/types.h> /* for user_size_t */
#include <spawn.h>
-#include <spawn_private.h>
#include <sys/spawn_internal.h>
#include <stdlib.h>
#include <errno.h>
@@ -99,12 +98,6 @@
/* Default is no port actions to take */
(*psattrp)->psa_ports = NULL;
-
- /*
- * The default value of this attribute shall be an no
- * process control on resource starvation
- */
- (*psattrp)->psa_pcontrol = 0;
}
return (err);
@@ -131,8 +124,6 @@
* NOTIMP: Allowed failures (checking NOT required):
* EINVAL The value specified by attr is invalid.
*/
-static int posix_spawn_destroyportactions_np(posix_spawnattr_t *);
-
int
posix_spawnattr_destroy(posix_spawnattr_t *attr)
{
@@ -366,43 +357,6 @@
*ocount = i;
return 0;
}
-
-
-/*
- * posix_spawnattr_getpcontrol_np
- *
- * Description: Retrieve the process control property set default according to
- * the spawn attribute value referenced by 'attr' and place the
- * result into the memory containing the control referenced by
- * 'pcontrol'
- *
- * Parameters: attr The spawn attributes object whose
- * signal set for default signals is to
- * be retrieved
- * pcontrol A pointer to an int to receive
- * the process control info
- *
- * Returns: 0 Success
- *
- * Implicit Returns:
- * *pcontrol (modified) The signal set of signals to default
- * from the spawn attributes object
- */
-int
-posix_spawnattr_getpcontrol_np(const posix_spawnattr_t * __restrict attr,
- int * __restrict pcontrol)
-{
- _posix_spawnattr_t psattr;
-
- if (attr == NULL || *attr == NULL)
- return EINVAL;
-
- psattr = *(_posix_spawnattr_t *)attr;
- *pcontrol = psattr->psa_pcontrol;
-
- return (0);
-}
-
/*
* posix_spawnattr_setsigdefault
*
@@ -535,41 +489,12 @@
return 0;
}
-
-/*
- * posix_spawnattr_setpcontrol_np
- *
- * Description: Set the process control property according to
- * attribute value referenced by 'attr' from the memory
- * containing the int value 'pcontrol'
- *
- * Parameters: attr The spawn attributes object whose
- * signal set for default signals is to
- * be set
- * pcontrol An int value of the process control info
- *
- * Returns: 0 Success
- */
-int
-posix_spawnattr_setpcontrol_np(posix_spawnattr_t * __restrict attr,
- const int pcontrol)
-{
- _posix_spawnattr_t psattr;
-
- if (attr == NULL || *attr == NULL)
- return EINVAL;
-
- psattr = *(_posix_spawnattr_t *)attr;
- psattr->psa_pcontrol = pcontrol;
-
- return (0);
-}
/*
* posix_spawn_createportactions_np
* Description: create a new posix_spawn_port_actions struct and link
* it into the posix_spawnattr.
*/
-static int
+int
posix_spawn_createportactions_np(posix_spawnattr_t *attr)
{
_posix_spawnattr_t psattr;
@@ -594,7 +519,7 @@
* posix_spawn_growportactions_np
* Description: Enlarge the size of portactions if necessary
*/
-static int
+int
posix_spawn_growportactions_np(posix_spawnattr_t *attr)
{
_posix_spawnattr_t psattr;
@@ -623,7 +548,7 @@
* posix_spawn_destroyportactions_np
* Description: clean up portactions struct in posix_spawnattr_t attr
*/
-static int
+int
posix_spawn_destroyportactions_np(posix_spawnattr_t *attr)
{
_posix_spawnattr_t psattr;
@@ -758,58 +683,6 @@
return err;
}
-/*
- * posix_spawnattr_setauditsessionport_np
- *
- * Description: Set the audit session port rights attribute in the spawned task.
- * This is used to securely set the audit session information for
- * the new task.
- *
- * Parameters: attr The spawn attributes object for the
- * new process
- * au_sessionport The audit session send port right
- *
- * Returns: 0 Success
- */
-int
-posix_spawnattr_setauditsessionport_np(
- posix_spawnattr_t *attr,
- mach_port_t au_sessionport)
-{
- _posix_spawnattr_t psattr;
- int err = 0;
- _ps_port_action_t *action;
- _posix_spawn_port_actions_t ports;
-
- if (attr == NULL || *attr == NULL)
- return EINVAL;
-
- psattr = *(_posix_spawnattr_t *)attr;
- ports = psattr->psa_ports;
- /* Have any port actions been created yet? */
- if (ports == NULL) {
- err = posix_spawn_createportactions_np(attr);
- if (err)
- return err;
- ports = psattr->psa_ports;
- }
-
- /* Is there enough room? */
- if (ports->pspa_alloc == ports->pspa_count) {
- err = posix_spawn_growportactions_np(attr);
- if (err)
- return err;
- }
-
- /* Add this action to next spot in array */
- action = &ports->pspa_actions[ports->pspa_count];
- action->port_type = PSPA_AU_SESSION;
- action->new_port = au_sessionport;
-
- ports->pspa_count++;
- return err;
-}
-
/*
* posix_spawn_file_actions_init
@@ -937,7 +810,7 @@
* opened with flags 'oflag' and mode 'mode', and, if successful,
* return as descriptor 'filedes' to the spawned process.
*
- * Parameters: file_actions File action object to augment
+ * Parameters: file_actions File action object to add open to
* filedes fd that open is to use
* path path to file to open
* oflag open file flags
@@ -999,7 +872,7 @@
* that will cause the file referenced by 'filedes' to be
* attempted to be closed in the spawned process.
*
- * Parameters: file_actions File action object to augment
+ * Parameters: file_actions File action object to add open to
* filedes fd to close
*
* Returns: 0 Success
@@ -1049,12 +922,12 @@
/*
* posix_spawn_file_actions_adddup2
*
- * Description: Add a dup2 action to the object referenced by 'file_actions'
+ * Description: Add a dpu2 action to the object referenced by 'file_actions'
* that will cause the file referenced by 'filedes' to be
* attempted to be dup2'ed to the descriptor 'newfiledes' in the
* spawned process.
*
- * Parameters: file_actions File action object to augment
+ * Parameters: file_actions File action object to add open to
* filedes fd to dup2
* newfiledes fd to dup2 it to
*
@@ -1100,73 +973,6 @@
psfileact->psfaa_filedes = filedes;
psfileact->psfaa_openargs.psfao_oflag = newfiledes;
- return (0);
-}
-
-/*
- * posix_spawn_file_actions_addinherit_np
- *
- * Description: Add the "inherit" action to the object referenced by
- * 'file_actions' that will cause the file referenced by
- * 'filedes' to continue to be available in the spawned
- * process via the same descriptor.
- *
- * Inheritance is the normal default behaviour for
- * file descriptors across exec and spawn; but if the
- * POSIX_SPAWN_CLOEXEC_DEFAULT flag is set, the usual
- * default is reversed for the purposes of the spawn
- * invocation. Any pre-existing descriptors that
- * need to be made available to the spawned process can
- * be marked explicitly as 'inherit' via this interface.
- * Otherwise they will be automatically closed.
- *
- * Note that any descriptors created via the other file
- * actions interfaces are automatically marked as 'inherit'.
- *
- * Parameters: file_actions File action object to augment
- * filedes fd to inherit.
- *
- * Returns: 0 Success
- * EBADF The value specified by fildes is
- * negative or greater than or equal to
- * {OPEN_MAX}.
- * ENOMEM Insufficient memory exists to add to
- * the spawn file actions object.
- *
- * NOTIMP: Allowed failures (checking NOT required):
- * EINVAL The value specified by file_actions is invalid.
- */
-int
-posix_spawn_file_actions_addinherit_np(posix_spawn_file_actions_t *file_actions,
- int filedes)
-{
- _posix_spawn_file_actions_t *psactsp;
- _psfa_action_t *psfileact;
-
- if (file_actions == NULL || *file_actions == NULL)
- return (EINVAL);
-
- psactsp = (_posix_spawn_file_actions_t *)file_actions;
- /* Range check; required by POSIX */
- if (filedes < 0 || filedes >= OPEN_MAX)
- return (EBADF);
-
-#if defined(POSIX_SPAWN_CLOEXEC_DEFAULT) // TODO: delete this check
- /* If we do not have enough slots, grow the structure */
- if ((*psactsp)->psfa_act_count == (*psactsp)->psfa_act_alloc) {
- /* need to grow file actions structure */
- if (_posix_spawn_file_actions_grow(psactsp))
- return (ENOMEM);
- }
-
- /*
- * Allocate next available slot and fill it out
- */
- psfileact = &(*psactsp)->psfa_act_acts[(*psactsp)->psfa_act_count++];
-
- psfileact->psfaa_type = PSFA_INHERIT;
- psfileact->psfaa_filedes = filedes;
-#endif
return (0);
}