INTEGER*4 system status = system( string ) |
|||
---|---|---|---|
string |
character*n |
Input |
String containing command to do |
Return value |
INTEGER*4 |
Output |
Exit status of the shell executed. See wait(2) for an explanation of this value. |
character*8 string / 'ls s*' / INTEGER*4 status, system status = system( string ) if ( status .ne. 0 ) stop 'system: error' end
The function system passes string to your shell as input, as if the string had been typed as a command. Note: string cannot be longer than 1024 characters.
If system can find the environment variable SHELL, then system uses the value of SHELL as the command interpreter (shell); otherwise, it uses sh(1).
The current process waits until the command terminates.
Historically, cc and f77 developed with different assumptions:
If cc calls system, the shell is always the Bourne shell.
If f77 calls system, then which shell is called depends on the environment variable SHELL.
The system function flushes all open files:
For output files, the buffer is flushed to the actual file.
For input files, the position of the pointer is unpredictable.
See also: execve(2), wait(2), and system(3).
The system() function is not MT-safe. Do not call it from multithreaded or parallelized programs.