with other subprocesses), and wait for it. Shared logic.
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004
Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
Libiberty is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with libiberty; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
Boston, MA 02110-1301, USA. */
#ifndef PEX_COMMON_H
#define PEX_COMMON_H
#include "config.h"
#include "libiberty.h"
#include <stdio.h>
included. */
#if !defined(pid_t) && defined(HAVE_SYS_TYPES_H)
#include <sys/types.h>
#endif
#define install_error_msg "installation problem, cannot exec `%s'"
#define STDIN_FILE_NO 0
#define STDOUT_FILE_NO 1
#define STDERR_FILE_NO 2
#define READ_PORT 0
#define WRITE_PORT 1
struct pex_obj
{
int flags;
const char *pname;
const char *tempbase;
int next_input;
char *next_input_name;
int next_input_name_allocated;
int stderr_pipe;
int count;
pid_t *children;
int *status;
struct pex_time *time;
int number_waited;
FILE *input_file;
FILE *read_output;
FILE *read_err;
int remove_count;
of strings allocated using malloc. */
char **remove;
const struct pex_funcs *funcs;
void *sysdep;
};
struct pex_funcs
{
binary mode. Return >= 0 on success, -1 on error. */
int (*open_read) (struct pex_obj *, const char *, int );
binary mode. Return >= 0 on success, -1 on error. */
int (*open_write) (struct pex_obj *, const char *,
int );
pex_run. IN, OUT, ERRDES, TOCLOSE are all descriptors, from
open_read, open_write, or pipe, or they are one of STDIN_FILE_NO,
STDOUT_FILE_NO or STDERR_FILE_NO; if IN, OUT, and ERRDES are not
STD*_FILE_NO, they should be closed. If the descriptor TOCLOSE
is not -1, and the system supports pipes, TOCLOSE should be
closed in the child process. The function should handle the
PEX_STDERR_TO_STDOUT flag. Return >= 0 on success, or -1 on
error and set *ERRMSG and *ERR. */
pid_t (*exec_child) (struct pex_obj *, int ,
const char *, char * const * ,
char * const * ,
int , int , int ,
int , const char **,
int *);
int (*close) (struct pex_obj *, int);
and time in *TIME (if it is not null). CHILD is from fork. DONE
is 1 if this is called via pex_free. ERRMSG and ERR are as in
fork. Return 0 on success, -1 on error. */
pid_t (*wait) (struct pex_obj *, pid_t , int * ,
struct pex_time * , int ,
const char ** , int * );
descriptors in P[0] and P[1]. If BINARY is non-zero, open in
binary mode. Return 0 on success, -1 on error. */
int (*pipe) (struct pex_obj *, int * , int );
PEX_USE_PIPES is set). If BINARY is non-zero, open in binary
mode. Return pointer on success, NULL on error. */
FILE * (*fdopenr) (struct pex_obj *, int , int );
called if PEX_USE_PIPES is set). If BINARY is non-zero, open in
binary mode. Arrange for FD not to be inherited by the child
processes. Return pointer on success, NULL on error. */
FILE * (*fdopenw) (struct pex_obj *, int , int );
NULL if there is nothing to do. */
void (*cleanup) (struct pex_obj *);
};
extern struct pex_obj *pex_init_common (int, const char *, const char *,
const struct pex_funcs *);
#endif