RUNPROCESS(3A) RUNPROCESS(3A)
NAME
RunProcess, RunProcessV - run a process with I/O redirection
SYNOPSIS
#include <Atari/procio.h>
RunProcess (io, cmd, arg ...)
struct procio *io;
char *cmd;
RunProcessV (io, cmd, argv)
struct procio *io;
char *cmd;
char **argv;
DESCRIPTION
RunProcess executes a process. I/O redirection and other
process information is described in the ProcessIO structure
pointed to by io. The full pathname of the command is in
cmd and its arguments follow beginning with arg (argument
zero) and terminated with a NULL argument. RunProcessV is
similar, except it expects an array of arguments (starting
with argument zero) in argv .
The ProcessIO structure is described in the include file
<Atari/procio.h> as follows:
struct ProcessIO {
int p_flags;
union IoInfo p_input;
union IoInfo p_output;
union IoInfo p_error;
};
union IoInfo {
struct {
char *io_name;
int io_oflags;
int io_operms;
Page 1 (printed 9/3/91)
RUNPROCESS(3A) RUNPROCESS(3A)
} i_open;
int i_fd;
FILE *i_file;
};
#define i_name i_open.io_name
#define i_oflags i_open.io_oflags
#define i_operms i_open.io_operms
The p_flags describes the I/O redirection and other process
attributes, and the IoInfo unions provide additional
information based on the values in p_flags. It is composed
of the bit-wise OR of the input modes for the three standard
file descriptor (input, output, and error) and other
attribute flags for the process.
The input mode can be extracted from the p_flags by bit-wise
AND-ing the p_flags with PROC_IMODE. The input mode should
then be one of the following values:
PROC_IPARENT Inherent the file descriptor from the parent.
PROC_INAME Open the file named in p_input.i_name with
the open flags in p_input.i_oflags and the
permissions in p_input.i_operms. These are
the three parameters passed to the open(2)
system call.
PROC_IPIPE Use pipe(2) to open a pipe and use the read
end of the pipe as standard input. Return
the write end of the pipe in p_input.i_fd.
PROC_IFD Use dup2(2) to duplicate the file descriptor
in p_input.i_fd for standard input.
PROC_IFILE Use dup2(2) to duplicate the file descriptor
in for the standard I/O FILE pointer in
p_input.i_file for standard input.
PROC_INULL Open /dev/null and use that as standard
input.
Page 2 (printed 9/3/91)
RUNPROCESS(3A) RUNPROCESS(3A)
Similarly, the output mode can be extracted from the p_flags
by bit-wise AND-ing the p_flags with PROC_OMODE. The output
mode should then be one of the following values:
PROC_OPARENT Inherent the file descriptor from the parent.
PROC_ONAME Open the file named in p_output.i_name with
the open flags in p_output.i_oflags and the
permissions in p_output.i_operms. These are
the three parameters passed to the open(2)
system call.
PROC_OPIPE Use pipe(2) to open a pipe and use the write
end of the pipe as standard output. Return
the read end of the pipe in p_output.i_fd.
PROC_OFD Use dup2(2) to duplicate the file descriptor
in p_output.i_fd for standard output.
PROC_OFILE Use dup2(2) to duplicate the file descriptor
in for the standard I/O FILE pointer in
p_output.i_file for standard output.
PROC_ONULL Open /dev/null and use that as standard
output.
Finally, the error output mode can be extracted from the
p_flags by bit-wise AND-ing the p_flags with PROC_EMODE.
The error output mode should then be one of the following
values:
PROC_EPARENT Inherent the file descriptor from the parent.
PROC_ENAME Open the file named in p_error.i_name with
the open flags in p_error.i_oflags and the
permissions in p_error.i_operms. These are
the three parameters passed to the open(2)
system call.
PROC_EPIPE Use pipe(2) to open a pipe and use the write
Page 3 (printed 9/3/91)
RUNPROCESS(3A) RUNPROCESS(3A)
end of the pipe as standard error. Return
the read end of the pipe in p_error.i_fd.
PROC_EFD Use dup2(2) to duplicate the file descriptor
in p_error.i_fd for standard error.
PROC_EOUTFD Use dup2(2) to duplicate standard output for
standard error.
PROC_EFILE Use dup2(2) to duplicate the file descriptor
in for the standard I/O FILE pointer in
p_error.i_file for standard error.
PROC_ENULL Open /dev/null and use that as standard
error.
There are also three attribute settings that may be set in
p_flags :
PROC_SETPGRP Set the process group of the process to
itself.
PROC_SETPTTY Set the process group of the controlling
terminal the child process.
PROC_BG Run the process in the background, i.e.,
ignore interrupt and quit signals.
The process ID of the child process is returned, or -1 if
there was an error.
NOTES
dup2(2), exec(2), fork(2), open(2), pipe(2), wait(2),
fopen(3), signal(3), null(7)
Page 4 (printed 9/3/91)