PXFEXECV(3F) Last changed: 2-24-98
PXFEXECV, PXFEXECVE, PXFEXECVP - Executes a new process image file
SUBROUTINE PXFEXECV (path, lenpath, argv, lenargv, iargc, ierror)
INTEGER lenpath, lenargv(0:iargc-1), iargc, ierror
CHARACTER*n path, argv(0:iargc-1)
SUBROUTINE PXFEXECVE (path, lenpath, argv, lenargv, iargc, env,
lenenv, ienvc, ierror)
INTEGER lenpath, lenargv(0:iargc-1), iargc, lenargv, ienvc, ierror
CHARACTER*n path, argv(0:iargc-1) env(ienvc)
SUBROUTINE PXFEXECVP (file, lenfile, argv, lenargv, iargc, ierror)
INTEGER lenfile, lenargv(0:iargc-1), iargc, ierror
CHARACTER*n file, argv(0:iargc-1)
UNICOS, UNICOS/mk, and IRIX systems
On IRIX systems, this routine is in libfortran.so which is linked by
default when compiling programs with the MIPSpro 7 Fortran 90 compiler
or when compiling programs with the -craylibs option to the MIPSpro
7.2 F77 compiler.
The PXFEXECV routine uses the execv(2) system call to replace the
current process image with a new process image.
The PXFEXECVE routine uses the execve(2) system call to replace the
current process image with a new process image. The environment
variables are not inherited from the calling process image. The
environment variables for the new process image are specified by the
env argument.
The PXFEXECVP routine uses the execvp(2) system call to replace the
current process image with a new process image.
When using the CF90 compiler or MIPSpro 7 Fortran 90 compiler on
UNICOS, UNICOS/mk, or IRIX systems, all arguments must be of default
kind unless documented otherwise. On UNICOS and UNICOS/mk, default
kind is KIND=8 for integer, real, complex, and logical arguments; on
IRIX, the default kind is KIND=4.
The following is a list of arguments for these routines:
path An input character variable or array element containing the
pathname of the new process image file.
lenpath An input integer variable for the length of path. If lenpath
is zero, trailing blanks are removed.
file An input character variable or array element containing the
file of the new process image file. If file contains a slash
character, file will be used as the pathname for the new
process image file. Otherwise, the directories listed in the
PATH environment variable are searched using each directory
in path as a pathname prefix for file.
lenfile An input integer variable for the length of file. If lenfile
is zero, trailing blanks are removed.
argv An input array of character strings. argv contains the
arguments to be passed to the new process image.
lenargv An input array of integers. Each element in lenargv contains
the length of the corresponding character string in argv. If
an element in lenargv is zero, the corresponding element in
argv has all trailing blanks stripped.
iargc An input integer variable. iargc contains the number of
arguments to pass to the new process image.
env An input array of character strings. env contains the
environment variables for the new process image.
lenenv An input array of integers. Each element in lenenv contains
the length of the corresponding character string in env. If
an element in lenenv is zero, the corresponding element in
env will have all trailing blanks stripped.
ienvc An input integer variable. ienvc contains the number of
environment variables for the new process image.
ierror An output integer variable that contains zero if the routine
was successful or nonzero if the routine was not successful.
The following values may be returned:
EACCES If the new process file is not a regular file, the new
process image file mode denies execution permission, or
search permission is denied for a directory listed in the
new process image file's path prefix.
ENOENT If one or more components of the new process image file's
path name do not exist.
ENOEXEC If the new process image file has the appropriate access
permission but an invalid magic number in its header.
ENOMEM If the memory needed to create structures used by the
routine could not be allocated.
EINVAL If lenpath < 0 or lenpath > LEN(path) or any element of
lenargv is less than zero or greater than the length of
the corresponding element in argv.
UNICOS and UNICOS/mk only errors:
E2BIG If the number of bytes in argv is greater than the
system-imposed limit of ARG_MAX found in <limits.h>.
EDMOFF If the process image file is offline, and the data
migration facility is not configured in the system.
EFAULT If the new process image file is not as long as indicated
by the size values in its header.
ENOMEM If the new process requires more memory than is allowed by
the system-imposed maximum MAXMEM.
EOFFLIN If the process image file is offline, and automatic file
retrieval is disabled.
EOFLNDD If the file is offline, and the data management daemon is
not currently executing.
EOFLNNR If the file is offline, and it is currently unretrievable.
IRIX 6.2 only errors:
E2BIG If the number of bytes in the new process's argument list
is greater than the system-imposed limit ARG_MAX (see
sysconf(2), intro(2), and limits.h). The argument list
limit is the sum of the size of the argument list plus the
size of the environment's exported shell variables.
E2BIG If the number of bytes in the first line of an interpreter
file is greater than 256 bytes.
EAGAIN If there is not enough memory.
ELIBACC If the required shared library does not have execute
permission.
ELIBEXEC If path points to a shared library.
ELIBMAX If the required number of shared libraries exceeds the
system imposed maximum SHLIB_MAX (see intro(2)).
ELOOP If too many symbolic links were encountered in translating
path.
ENAMETOOLONG [Toc] [Back]
If the length of path exceeds PATH_MAX found in
<limits.h>, or the length of a path component exceeds
NAME_MAX found in <limits.h> while POSIX_NO_TRUNC is in
effect.
ENOEXEC If the executable process image file has badly formed
header information or the requested virtual addresses are
not available.
ENOMEM If the new process image requires more virtual space than
is allowed either by the system-imposed maximum or the
process imposed maximum PROCSIZE_MAX (see getrlimit(2) and
intro(2)).
EPERM If a non-superuser tries to execute a setuid file that
belongs to some other user and the file system in which
the file resides has been mounted with the nosuid option
(see fstab(4)), or if a non-superuser attempts to execute
a setuid or setgid shell script with a UID or GID that is
different than the user's effective UID/GID, and the
configured value for no-suid-shells is non-zero (the
default) (see intro(2) and lboot(1M)).
PXFEXECV example:
In this example, the program forks and the child calls PXFEXECV to
execute the /bin/grep process image file. The parent process waits for
the child to finish executing and then forks again. The child from the
second fork also calls PXFEXECV to execute the /bin/grep process image
file. The parent then waits for the child to finish executing.
program test
integer ipid, ierror, lenpath, lenargv(3), iargc, iretpid
integer istat
character*30 path, argv(3)
path = '/bin/grep'
lenpath = 0
iargc = 3
argv(1) = 'grep'
lenargv(1) = 0
argv(2) = 'root'
lenargv(2) = 0
argv(3) = '/etc/passwd'
lenargv(3) = 0
CALL PXFFORK(ipid,ierror)
if (ierror .ne. 0) then
print *,'FAILED: PXFFORK call with error = ',ierror
else
if (ipid .eq. 0) then
print *,'CHILD1: execing grep'
CALL PXFEXECV(path, lenpath, argv, lenargv, iargc, ierror)
print *,'FAILED: PXFEXEC call with error = ',ierror
stop
else
print *,'PARENT: waiting for CHILD1'
CALL PXFWAIT(istat,iretpid,ierror)
print *,'PARENT: CHILD1 finished. Forking off CHILD2'
CALL PXFFORK(ipid, ierror)
if (ipid .eq. 0) then
print *,'CHILD2: execing grep'
CALL PXFEXECV(path, lenpath, argv, lenargv, iargc, ierror)
print *,'FAILED PXFEXEC call with error = ',ierror
stop
else
print *,'PARENT: waiting for CHILD2'
CALL PXFWAIT(istat,iretpid,ierror)
print *,'PARENT: CHILD2 finished.'
print *,'PASSED: PXFEXECV normal test'
endif
endif
endif
end
PXFEXECVE example:
In this example, the program forks and the child calls PXFEXECVE to
execute the /bin/grep process image file. The parent process waits for
the child to finish executing and then forks again. The child from the
second fork also calls PXFEXECVE to execute the /bin/grep process
image file. The parent then waits for the child to finish executing.
integer ipid, ierror, lenpath, lenargv(3), iargc, iretpid
integer istat, errorcondition, lenenv(3), ienvc
character*30 path, arg
path = '/bin/grep'
lenpath = 0
iargc = 3
argv(1) = 'grep'
lenargv(1) = 0
argv(2) = 'root'
lenargv(2) = 0
argv(3) = '/etc/passwd'
lenargv(3) = 0
ienvc = 3
env(1) = 'TERM=vt100'
lenenv(1) = 0
env(2) = 'SHELL=/bin/csh'
lenenv(2) = 0
env(3) = 'DISPLAY=:0.0'
lenenv(3) = 0
CALL PXFFORK(ipid,ierror)
if (ierror .ne. 0) then
print *,'FAILED: PXFFORK call with error = ',ierror
else
if (ipid .eq. 0) then
print *,'CHILD1: execing grep'
CALL PXFEXECV(path, lenpath, argv, lenargv, iargc, ierror)
print *,'FAILED: PXFEXEC call with error = ',ierror
stop
else
print *,'PARENT: waiting for CHILD1'
CALL PXFWAIT(istat,iretpid,ierror)
print *,'PARENT: CHILD1 finished. Forking off CHILD2'
CALL PXFFORK(ipid, ierror)
if (ipid .eq. 0) then
print *,'CHILD2: execing grep'
CALL PXFEXECV(path, lenpath, argv, lenargv, iargc, ierror)
print *,'FAILED PXFEXEC call with error = ',ierror
stop
else
print *,'PARENT: waiting for CHILD2'
CALL PXFWAIT(istat,iretpid,ierror)
print *,'PARENT: CHILD2 finished.'
print *,'PASSED: PXFEXECVP normal test'
endif
endif
endif
end
PXFEXECVP example:
In this example, the program forks and the child calls PXFEXECVP to
execute the grep process image file. The parent process waits for the
child to finish executing and then forks again. The child from the
second fork also calls PXFEXECVP to execute the grep process image
file. The parent then waits for the child to finish executing.
program test
integer ipid, ierror, lenfile, lenargv(3), iargc, iretpid
integer istat
character*30 file, argv(3)
file = 'grep'
lenfile = 0
iargc = 3
argv(1) = 'grep'
lenargv(1) = 0
argv(2) = 'root'
lenargv(2) = 0
argv(3) = '/etc/passwd'
lenargv(3) = 0
CALL PXFFORK(ipid,ierror)
if (ierror .ne. 0) then
print *,'FAILED: PXFFORK call with error = ',ierror
else
if (ipid .eq. 0) then
print *,'CHILD1: execing grep'
CALL PXFEXECVP(file, lenfile, argv, lenargv, iargc, ierror)
print *,'FAILED: PXFEXEC call with error = ',ierror
stop
else
print *,'PARENT: waiting for CHILD1'
CALL PXFWAIT(istat,iretpid,ierror)
print *,'PARENT: CHILD1 finished. Forking off CHILD2'
CALL PXFFORK(ipid, ierror)
if (ipid .eq. 0) then
print *,'CHILD2: execing grep'
CALL PXFEXECVP(file, lenfile, argv, lenargv, iargc, ierror)
print *,'FAILED PXFEXEC call with error = ',ierror
stop
else
print *,'PARENT: waiting for CHILD2'
CALL PXFWAIT(istat,iretpid,ierror)
print *,'PARENT: CHILD2 finished.'
print *,'PASSED: PXFEXECVP normal test'
endif
endif
endif
end
execv(2)
Application Programmer's Library Reference Manual, publication
SR-2165, for the printed version of this man page.
PXFEXECV(3F) Last changed: 2-24-98
PXFEXECV, PXFEXECVE, PXFEXECVP - Executes a new process image file
SUBROUTINE PXFEXECV (path, lenpath, argv, lenargv, iargc, ierror)
INTEGER lenpath, lenargv(0:iargc-1), iargc, ierror
CHARACTER*n path, argv(0:iargc-1)
SUBROUTINE PXFEXECVE (path, lenpath, argv, lenargv, iargc, env,
lenenv, ienvc, ierror)
INTEGER lenpath, lenargv(0:iargc-1), iargc, lenargv, ienvc, ierror
CHARACTER*n path, argv(0:iargc-1) env(ienvc)
SUBROUTINE PXFEXECVP (file, lenfile, argv, lenargv, iargc, ierror)
INTEGER lenfile, lenargv(0:iargc-1), iargc, ierror
CHARACTER*n file, argv(0:iargc-1)
UNICOS, UNICOS/mk, and IRIX systems
On IRIX systems, this routine is in libfortran.so which is linked by
default when compiling programs with the MIPSpro 7 Fortran 90 compiler
or when compiling programs with the -craylibs option to the MIPSpro
7.2 F77 compiler.
The PXFEXECV routine uses the execv(2) system call to replace the
current process image with a new process image.
The PXFEXECVE routine uses the execve(2) system call to replace the
current process image with a new process image. The environment
variables are not inherited from the calling process image. The
environment variables for the new process image are specified by the
env argument.
The PXFEXECVP routine uses the execvp(2) system call to replace the
current process image with a new process image.
When using the CF90 compiler or MIPSpro 7 Fortran 90 compiler on
UNICOS, UNICOS/mk, or IRIX systems, all arguments must be of default
kind unless documented otherwise. On UNICOS and UNICOS/mk, default
kind is KIND=8 for integer, real, complex, and logical arguments; on
IRIX, the default kind is KIND=4.
The following is a list of arguments for these routines:
path An input character variable or array element containing the
pathname of the new process image file.
lenpath An input integer variable for the length of path. If lenpath
is zero, trailing blanks are removed.
file An input character variable or array element containing the
file of the new process image file. If file contains a slash
character, file will be used as the pathname for the new
process image file. Otherwise, the directories listed in the
PATH environment variable are searched using each directory
in path as a pathname prefix for file.
lenfile An input integer variable for the length of file. If lenfile
is zero, trailing blanks are removed.
argv An input array of character strings. argv contains the
arguments to be passed to the new process image.
lenargv An input array of integers. Each element in lenargv contains
the length of the corresponding character string in argv. If
an element in lenargv is zero, the corresponding element in
argv has all trailing blanks stripped.
iargc An input integer variable. iargc contains the number of
arguments to pass to the new process image.
env An input array of character strings. env contains the
environment variables for the new process image.
lenenv An input array of integers. Each element in lenenv contains
the length of the corresponding character string in env. If
an element in lenenv is zero, the corresponding element in
env will have all trailing blanks stripped.
ienvc An input integer variable. ienvc contains the number of
environment variables for the new process image.
ierror An output integer variable that contains zero if the routine
was successful or nonzero if the routine was not successful.
The following values may be returned:
EACCES If the new process file is not a regular file, the new
process image file mode denies execution permission, or
search permission is denied for a directory listed in the
new process image file's path prefix.
ENOENT If one or more components of the new process image file's
path name do not exist.
ENOEXEC If the new process image file has the appropriate access
permission but an invalid magic number in its header.
ENOMEM If the memory needed to create structures used by the
routine could not be allocated.
EINVAL If lenpath < 0 or lenpath > LEN(path) or any element of
lenargv is less than zero or greater than the length of
the corresponding element in argv.
UNICOS and UNICOS/mk only errors:
E2BIG If the number of bytes in argv is greater than the
system-imposed limit of ARG_MAX found in <limits.h>.
EDMOFF If the process image file is offline, and the data
migration facility is not configured in the system.
EFAULT If the new process image file is not as long as indicated
by the size values in its header.
ENOMEM If the new process requires more memory than is allowed by
the system-imposed maximum MAXMEM.
EOFFLIN If the process image file is offline, and automatic file
retrieval is disabled.
EOFLNDD If the file is offline, and the data management daemon is
not currently executing.
EOFLNNR If the file is offline, and it is currently unretrievable.
IRIX 6.2 only errors:
E2BIG If the number of bytes in the new process's argument list
is greater than the system-imposed limit ARG_MAX (see
sysconf(2), intro(2), and limits.h). The argument list
limit is the sum of the size of the argument list plus the
size of the environment's exported shell variables.
E2BIG If the number of bytes in the first line of an interpreter
file is greater than 256 bytes.
EAGAIN If there is not enough memory.
ELIBACC If the required shared library does not have execute
permission.
ELIBEXEC If path points to a shared library.
ELIBMAX If the required number of shared libraries exceeds the
system imposed maximum SHLIB_MAX (see intro(2)).
ELOOP If too many symbolic links were encountered in translating
path.
ENAMETOOLONG [Toc] [Back]
If the length of path exceeds PATH_MAX found in
<limits.h>, or the length of a path component exceeds
NAME_MAX found in <limits.h> while POSIX_NO_TRUNC is in
effect.
ENOEXEC If the executable process image file has badly formed
header information or the requested virtual addresses are
not available.
ENOMEM If the new process image requires more virtual space than
is allowed either by the system-imposed maximum or the
process imposed maximum PROCSIZE_MAX (see getrlimit(2) and
intro(2)).
EPERM If a non-superuser tries to execute a setuid file that
belongs to some other user and the file system in which
the file resides has been mounted with the nosuid option
(see fstab(4)), or if a non-superuser attempts to execute
a setuid or setgid shell script with a UID or GID that is
different than the user's effective UID/GID, and the
configured value for no-suid-shells is non-zero (the
default) (see intro(2) and lboot(1M)).
PXFEXECV example:
In this example, the program forks and the child calls PXFEXECV to
execute the /bin/grep process image file. The parent process waits for
the child to finish executing and then forks again. The child from the
second fork also calls PXFEXECV to execute the /bin/grep process image
file. The parent then waits for the child to finish executing.
program test
integer ipid, ierror, lenpath, lenargv(3), iargc, iretpid
integer istat
character*30 path, argv(3)
path = '/bin/grep'
lenpath = 0
iargc = 3
argv(1) = 'grep'
lenargv(1) = 0
argv(2) = 'root'
lenargv(2) = 0
argv(3) = '/etc/passwd'
lenargv(3) = 0
CALL PXFFORK(ipid,ierror)
if (ierror .ne. 0) then
print *,'FAILED: PXFFORK call with error = ',ierror
else
if (ipid .eq. 0) then
print *,'CHILD1: execing grep'
CALL PXFEXECV(path, lenpath, argv, lenargv, iargc, ierror)
print *,'FAILED: PXFEXEC call with error = ',ierror
stop
else
print *,'PARENT: waiting for CHILD1'
CALL PXFWAIT(istat,iretpid,ierror)
print *,'PARENT: CHILD1 finished. Forking off CHILD2'
CALL PXFFORK(ipid, ierror)
if (ipid .eq. 0) then
print *,'CHILD2: execing grep'
CALL PXFEXECV(path, lenpath, argv, lenargv, iargc, ierror)
print *,'FAILED PXFEXEC call with error = ',ierror
stop
else
print *,'PARENT: waiting for CHILD2'
CALL PXFWAIT(istat,iretpid,ierror)
print *,'PARENT: CHILD2 finished.'
print *,'PASSED: PXFEXECV normal test'
endif
endif
endif
end
PXFEXECVE example:
In this example, the program forks and the child calls PXFEXECVE to
execute the /bin/grep process image file. The parent process waits for
the child to finish executing and then forks again. The child from the
second fork also calls PXFEXECVE to execute the /bin/grep process
image file. The parent then waits for the child to finish executing.
integer ipid, ierror, lenpath, lenargv(3), iargc, iretpid
integer istat, errorcondition, lenenv(3), ienvc
character*30 path, arg
path = '/bin/grep'
lenpath = 0
iargc = 3
argv(1) = 'grep'
lenargv(1) = 0
argv(2) = 'root'
lenargv(2) = 0
argv(3) = '/etc/passwd'
lenargv(3) = 0
ienvc = 3
env(1) = 'TERM=vt100'
lenenv(1) = 0
env(2) = 'SHELL=/bin/csh'
lenenv(2) = 0
env(3) = 'DISPLAY=:0.0'
lenenv(3) = 0
CALL PXFFORK(ipid,ierror)
if (ierror .ne. 0) then
print *,'FAILED: PXFFORK call with error = ',ierror
else
if (ipid .eq. 0) then
print *,'CHILD1: execing grep'
CALL PXFEXECV(path, lenpath, argv, lenargv, iargc, ierror)
print *,'FAILED: PXFEXEC call with error = ',ierror
stop
else
print *,'PARENT: waiting for CHILD1'
CALL PXFWAIT(istat,iretpid,ierror)
print *,'PARENT: CHILD1 finished. Forking off CHILD2'
CALL PXFFORK(ipid, ierror)
if (ipid .eq. 0) then
print *,'CHILD2: execing grep'
CALL PXFEXECV(path, lenpath, argv, lenargv, iargc, ierror)
print *,'FAILED PXFEXEC call with error = ',ierror
stop
else
print *,'PARENT: waiting for CHILD2'
CALL PXFWAIT(istat,iretpid,ierror)
print *,'PARENT: CHILD2 finished.'
print *,'PASSED: PXFEXECVP normal test'
endif
endif
endif
end
PXFEXECVP example:
In this example, the program forks and the child calls PXFEXECVP to
execute the grep process image file. The parent process waits for the
child to finish executing and then forks again. The child from the
second fork also calls PXFEXECVP to execute the grep process image
file. The parent then waits for the child to finish executing.
program test
integer ipid, ierror, lenfile, lenargv(3), iargc, iretpid
integer istat
character*30 file, argv(3)
file = 'grep'
lenfile = 0
iargc = 3
argv(1) = 'grep'
lenargv(1) = 0
argv(2) = 'root'
lenargv(2) = 0
argv(3) = '/etc/passwd'
lenargv(3) = 0
CALL PXFFORK(ipid,ierror)
if (ierror .ne. 0) then
print *,'FAILED: PXFFORK call with error = ',ierror
else
if (ipid .eq. 0) then
print *,'CHILD1: execing grep'
CALL PXFEXECVP(file, lenfile, argv, lenargv, iargc, ierror)
print *,'FAILED: PXFEXEC call with error = ',ierror
stop
else
print *,'PARENT: waiting for CHILD1'
CALL PXFWAIT(istat,iretpid,ierror)
print *,'PARENT: CHILD1 finished. Forking off CHILD2'
CALL PXFFORK(ipid, ierror)
if (ipid .eq. 0) then
print *,'CHILD2: execing grep'
CALL PXFEXECVP(file, lenfile, argv, lenargv, iargc, ierror)
print *,'FAILED PXFEXEC call with error = ',ierror
stop
else
print *,'PARENT: waiting for CHILD2'
CALL PXFWAIT(istat,iretpid,ierror)
print *,'PARENT: CHILD2 finished.'
print *,'PASSED: PXFEXECVP normal test'
endif
endif
endif
end
execv(2)
Application Programmer's Library Reference Manual, publication
SR-2165, for the printed version of this man page.
[ Back ]
|