hjl / source-git / glibc

Forked from source-git/glibc 3 years ago
Clone

Blame posix/spawn.h

Packit 6c4009
/* Definitions for POSIX spawn interface.
Packit 6c4009
   Copyright (C) 2000-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#ifndef	_SPAWN_H
Packit 6c4009
#define	_SPAWN_H	1
Packit 6c4009
Packit 6c4009
#include <features.h>
Packit 6c4009
#include <sched.h>
Packit 6c4009
#include <sys/types.h>
Packit 6c4009
#include <bits/types/sigset_t.h>
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Data structure to contain attributes for thread creation.  */
Packit 6c4009
typedef struct
Packit 6c4009
{
Packit 6c4009
  short int __flags;
Packit 6c4009
  pid_t __pgrp;
Packit 6c4009
  sigset_t __sd;
Packit 6c4009
  sigset_t __ss;
Packit 6c4009
  struct sched_param __sp;
Packit 6c4009
  int __policy;
Packit 6c4009
  int __pad[16];
Packit 6c4009
} posix_spawnattr_t;
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Data structure to contain information about the actions to be
Packit 6c4009
   performed in the new process with respect to file descriptors.  */
Packit 6c4009
typedef struct
Packit 6c4009
{
Packit 6c4009
  int __allocated;
Packit 6c4009
  int __used;
Packit 6c4009
  struct __spawn_action *__actions;
Packit 6c4009
  int __pad[16];
Packit 6c4009
} posix_spawn_file_actions_t;
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Flags to be set in the `posix_spawnattr_t'.  */
Packit 6c4009
#define POSIX_SPAWN_RESETIDS		0x01
Packit 6c4009
#define POSIX_SPAWN_SETPGROUP		0x02
Packit 6c4009
#define POSIX_SPAWN_SETSIGDEF		0x04
Packit 6c4009
#define POSIX_SPAWN_SETSIGMASK		0x08
Packit 6c4009
#define POSIX_SPAWN_SETSCHEDPARAM	0x10
Packit 6c4009
#define POSIX_SPAWN_SETSCHEDULER	0x20
Packit 6c4009
#ifdef __USE_GNU
Packit 6c4009
# define POSIX_SPAWN_USEVFORK		0x40
Packit 6c4009
# define POSIX_SPAWN_SETSID		0x80
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
Packit 6c4009
__BEGIN_DECLS
Packit 6c4009
Packit 6c4009
/* Spawn a new process executing PATH with the attributes describes in *ATTRP.
Packit 6c4009
   Before running the process perform the actions described in FILE-ACTIONS.
Packit 6c4009
Packit 6c4009
   This function is a possible cancellation point and therefore not
Packit 6c4009
   marked with __THROW. */
Packit 6c4009
extern int posix_spawn (pid_t *__restrict __pid,
Packit 6c4009
			const char *__restrict __path,
Packit 6c4009
			const posix_spawn_file_actions_t *__restrict
Packit 6c4009
			__file_actions,
Packit 6c4009
			const posix_spawnattr_t *__restrict __attrp,
Packit 6c4009
			char *const __argv[__restrict_arr],
Packit 6c4009
			char *const __envp[__restrict_arr]);
Packit 6c4009
Packit 6c4009
/* Similar to `posix_spawn' but search for FILE in the PATH.
Packit 6c4009
Packit 6c4009
   This function is a possible cancellation point and therefore not
Packit 6c4009
   marked with __THROW.  */
Packit 6c4009
extern int posix_spawnp (pid_t *__pid, const char *__file,
Packit 6c4009
			 const posix_spawn_file_actions_t *__file_actions,
Packit 6c4009
			 const posix_spawnattr_t *__attrp,
Packit 6c4009
			 char *const __argv[], char *const __envp[]);
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Initialize data structure with attributes for `spawn' to default values.  */
Packit 6c4009
extern int posix_spawnattr_init (posix_spawnattr_t *__attr) __THROW;
Packit 6c4009
Packit 6c4009
/* Free resources associated with ATTR.  */
Packit 6c4009
extern int posix_spawnattr_destroy (posix_spawnattr_t *__attr) __THROW;
Packit 6c4009
Packit 6c4009
/* Store signal mask for signals with default handling from ATTR in
Packit 6c4009
   SIGDEFAULT.  */
Packit 6c4009
extern int posix_spawnattr_getsigdefault (const posix_spawnattr_t *
Packit 6c4009
					  __restrict __attr,
Packit 6c4009
					  sigset_t *__restrict __sigdefault)
Packit 6c4009
     __THROW;
Packit 6c4009
Packit 6c4009
/* Set signal mask for signals with default handling in ATTR to SIGDEFAULT.  */
Packit 6c4009
extern int posix_spawnattr_setsigdefault (posix_spawnattr_t *__restrict __attr,
Packit 6c4009
					  const sigset_t *__restrict
Packit 6c4009
					  __sigdefault)
Packit 6c4009
     __THROW;
Packit 6c4009
Packit 6c4009
/* Store signal mask for the new process from ATTR in SIGMASK.  */
Packit 6c4009
extern int posix_spawnattr_getsigmask (const posix_spawnattr_t *__restrict
Packit 6c4009
				       __attr,
Packit 6c4009
				       sigset_t *__restrict __sigmask) __THROW;
Packit 6c4009
Packit 6c4009
/* Set signal mask for the new process in ATTR to SIGMASK.  */
Packit 6c4009
extern int posix_spawnattr_setsigmask (posix_spawnattr_t *__restrict __attr,
Packit 6c4009
				       const sigset_t *__restrict __sigmask)
Packit 6c4009
     __THROW;
Packit 6c4009
Packit 6c4009
/* Get flag word from the attribute structure.  */
Packit 6c4009
extern int posix_spawnattr_getflags (const posix_spawnattr_t *__restrict
Packit 6c4009
				     __attr,
Packit 6c4009
				     short int *__restrict __flags) __THROW;
Packit 6c4009
Packit 6c4009
/* Store flags in the attribute structure.  */
Packit 6c4009
extern int posix_spawnattr_setflags (posix_spawnattr_t *_attr,
Packit 6c4009
				     short int __flags) __THROW;
Packit 6c4009
Packit 6c4009
/* Get process group ID from the attribute structure.  */
Packit 6c4009
extern int posix_spawnattr_getpgroup (const posix_spawnattr_t *__restrict
Packit 6c4009
				      __attr, pid_t *__restrict __pgroup)
Packit 6c4009
     __THROW;
Packit 6c4009
Packit 6c4009
/* Store process group ID in the attribute structure.  */
Packit 6c4009
extern int posix_spawnattr_setpgroup (posix_spawnattr_t *__attr,
Packit 6c4009
				      pid_t __pgroup) __THROW;
Packit 6c4009
Packit 6c4009
/* Get scheduling policy from the attribute structure.  */
Packit 6c4009
extern int posix_spawnattr_getschedpolicy (const posix_spawnattr_t *
Packit 6c4009
					   __restrict __attr,
Packit 6c4009
					   int *__restrict __schedpolicy)
Packit 6c4009
     __THROW;
Packit 6c4009
Packit 6c4009
/* Store scheduling policy in the attribute structure.  */
Packit 6c4009
extern int posix_spawnattr_setschedpolicy (posix_spawnattr_t *__attr,
Packit 6c4009
					   int __schedpolicy) __THROW;
Packit 6c4009
Packit 6c4009
/* Get scheduling parameters from the attribute structure.  */
Packit 6c4009
extern int posix_spawnattr_getschedparam (const posix_spawnattr_t *
Packit 6c4009
					  __restrict __attr,
Packit 6c4009
					  struct sched_param *__restrict
Packit 6c4009
					  __schedparam) __THROW;
Packit 6c4009
Packit 6c4009
/* Store scheduling parameters in the attribute structure.  */
Packit 6c4009
extern int posix_spawnattr_setschedparam (posix_spawnattr_t *__restrict __attr,
Packit 6c4009
					  const struct sched_param *
Packit 6c4009
					  __restrict __schedparam) __THROW;
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Initialize data structure for file attribute for `spawn' call.  */
Packit 6c4009
extern int posix_spawn_file_actions_init (posix_spawn_file_actions_t *
Packit 6c4009
					  __file_actions) __THROW;
Packit 6c4009
Packit 6c4009
/* Free resources associated with FILE-ACTIONS.  */
Packit 6c4009
extern int posix_spawn_file_actions_destroy (posix_spawn_file_actions_t *
Packit 6c4009
					     __file_actions) __THROW;
Packit 6c4009
Packit 6c4009
/* Add an action to FILE-ACTIONS which tells the implementation to call
Packit 6c4009
   `open' for the given file during the `spawn' call.  */
Packit 6c4009
extern int posix_spawn_file_actions_addopen (posix_spawn_file_actions_t *
Packit 6c4009
					     __restrict __file_actions,
Packit 6c4009
					     int __fd,
Packit 6c4009
					     const char *__restrict __path,
Packit 6c4009
					     int __oflag, mode_t __mode)
Packit 6c4009
     __THROW;
Packit 6c4009
Packit 6c4009
/* Add an action to FILE-ACTIONS which tells the implementation to call
Packit 6c4009
   `close' for the given file descriptor during the `spawn' call.  */
Packit 6c4009
extern int posix_spawn_file_actions_addclose (posix_spawn_file_actions_t *
Packit 6c4009
					      __file_actions, int __fd)
Packit 6c4009
     __THROW;
Packit 6c4009
Packit 6c4009
/* Add an action to FILE-ACTIONS which tells the implementation to call
Packit 6c4009
   `dup2' for the given file descriptors during the `spawn' call.  */
Packit 6c4009
extern int posix_spawn_file_actions_adddup2 (posix_spawn_file_actions_t *
Packit 6c4009
					     __file_actions,
Packit 6c4009
					     int __fd, int __newfd) __THROW;
Packit 6c4009
Packit 6c4009
__END_DECLS
Packit 6c4009
Packit 6c4009
#endif /* spawn.h */