summaryrefslogtreecommitdiff
path: root/gcc/fortran/intrinsic.texi
diff options
context:
space:
mode:
authorfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>2010-09-01 08:33:11 +0000
committerfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>2010-09-01 08:33:11 +0000
commitfe2de951b1669a22661733f2f4496f7bcf2f02f2 (patch)
tree152b99416a290e053058a7bd41350fbc94980279 /gcc/fortran/intrinsic.texi
parent278afeb5162b74e6c1f62687c48b0c437fa7eb83 (diff)
downloadgcc-fe2de951b1669a22661733f2f4496f7bcf2f02f2.tar.gz
* intrinsic.c: Add EXECUTE_COMMAND_LINE intrinsic.
* intrinsic.h (gfc_resolve_execute_command_line): New function. * iresolve.c (gfc_resolve_execute_command_line): New function. * gfortran.h (GFC_ISYM_EXECUTE_COMMAND_LINE): New value. * intrinsic.texi: Document EXECUTE_COMMAND_LINE. * intrinsics/execute_command_line.c: New file. * gfortran.map (_gfortran_execute_command_line_i4, _gfortran_execute_command_line_i8): New symbols. * Makefile.am: Add new file intrinsics/execute_command_line.c. * Makefile.in: Regenerated. * gfortran.dg/execute_command_line_1.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@163719 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/intrinsic.texi')
-rw-r--r--gcc/fortran/intrinsic.texi79
1 files changed, 79 insertions, 0 deletions
diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi
index 49b9d53f540..6603fb59b0b 100644
--- a/gcc/fortran/intrinsic.texi
+++ b/gcc/fortran/intrinsic.texi
@@ -104,6 +104,7 @@ Some basic guidelines for editing this document:
* @code{ERFC}: ERFC, Complementary error function
* @code{ERFC_SCALED}: ERFC_SCALED, Exponentially-scaled complementary error function
* @code{ETIME}: ETIME, Execution time subroutine (or function)
+* @code{EXECUTE_COMMAND_LINE}: EXECUTE_COMMAND_LINE, Execute a shell command
* @code{EXIT}: EXIT, Exit the program with status.
* @code{EXP}: EXP, Exponential function
* @code{EXPONENT}: EXPONENT, Exponent function
@@ -3817,6 +3818,82 @@ end program test_etime
+@node EXECUTE_COMMAND_LINE
+@section @code{EXECUTE_COMMAND_LINE} --- Execute a shell command
+@fnindex EXECUTE_COMMAND_LINE
+@cindex system, system call
+@cindex command line
+
+@table @asis
+@item @emph{Description}:
+@code{EXECUTE_COMMAND_LINE} runs a shell command, synchronously or
+asynchronously.
+
+The @code{COMMAND} argument is passed to the shell and executed, using
+the C library's @code{system()} call. (The shell is @code{sh} on Unix
+systems, and @code{cmd.exe} on Windows.) If @code{WAIT} is present and
+has the value false, the execution of the command is asynchronous if the
+system supports it; otherwise, the command is executed synchronously.
+
+The three last arguments allow the user to get status information. After
+synchronous execution, @code{EXITSTAT} contains the integer exit code of
+the command, as returned by @code{system}. @code{CMDSTAT} is set to zero
+if the command line was executed (whatever its exit status was).
+@code{CMDMSG} is assigned an error message if an error has occurred.
+
+
+@item @emph{Standard}:
+Fortran 2008 and later
+
+@item @emph{Class}:
+Subroutine
+
+@item @emph{Syntax}:
+@code{CALL EXECUTE_COMMAND_LINE(COMMAND [, WAIT, EXITSTAT, CMDSTAT, CMDMSG ])}
+
+@item @emph{Arguments}:
+@multitable @columnfractions .15 .70
+@item @var{COMMAND} @tab Shall be a default @code{CHARACTER} scalar.
+@item @var{WAIT} @tab (Optional) Shall be a default @code{LOGICAL} scalar.
+@item @var{EXITSTAT} @tab (Optional) Shall be an @code{INTEGER} of the
+default kind.
+@item @var{CMDSTAT} @tab (Optional) Shall be an @code{INTEGER} of the
+default kind.
+@item @var{CMDMSG} @tab (Optional) Shall be an @code{CHARACTER} scalar of the
+default kind.
+@end multitable
+
+@item @emph{Example}:
+@smallexample
+program test_exec
+ integer :: i
+
+ call execute_command_line ("external_prog.exe", exitstat=i)
+ print *, "Exit status of external_prog.exe was ", i
+
+ call execute_command_line ("reindex_files.exe", wait=.false.)
+ print *, "Now reindexing files in the background"
+
+end program test_exec
+@end smallexample
+
+
+@item @emph{Note}:
+
+Because this intrinsic is implemented in terms of the @code{system()}
+function call, its behavior with respect to signalling is processor
+dependent. In particular, on POSIX-compliant systems, the SIGINT and
+SIGQUIT signals will be ignored, and the SIGCHLD will be blocked. As
+such, if the parent process is terminated, the child process might not be
+terminated alongside.
+
+
+@item @emph{See also}:
+@ref{SYSTEM}
+@end table
+
+
+
@node EXIT
@section @code{EXIT} --- Exit the program with status.
@fnindex EXIT
@@ -10955,6 +11032,8 @@ Subroutine, function
@end multitable
@item @emph{See also}:
+@ref{EXECUTE_COMMAND_LINE}, which is part of the Fortran 2008 standard
+and should considered in new code for future portability.
@end table