Problem with Fortan system(3F) and open files

Jonathan Eisenhamer jon at astro.ucla.edu
Sat Mar 11 16:45:24 AEST 1989


To All Spots,

A problem has been noted with the procedure system(3F) in fortran.  Below
is an example program + input file.  The problem is that all opened files
are truncated as soon as a call to system(3F) is made.  For the program
below, the first line is read, the system call is made, and when the
second line read is attempted, it ends on the EOF statement.  If the
system call is removed, it works fine.  If  system(3F) is replaced with a
call to a C routine which just calls system(3), the program also works
fine.

Stdin, etc, are also affected.  This can be seen by removing the open
statement and changing the "read (20..." to "read( *..." and performing
the command: "cat testinput | a.out"

Is this a known bug with system(3F)? or is this a "feature"?  This is
under 3.5SunOs.

	Thanks for your time,
	Jonathan Eisenhamer
	jon at astro.ucla.edu
	jon at uclastro.bitnet
	bonnie::jon (span 5.708)
__________

      program fd

      character*40 line

      open( 20, file='./testinput' )
      call system( 'echo "We are calling the system"' )

 10      read(20, '(a)', end=999, err=900) line
         write( *, * ) line
         call system( 'echo "We are calling the system"' )
         goto 10

 900  continue
      write( *, * ) 'It errored out.'
 999  continue
      write( *, * ) 'File is closing.'
      close( 20 )
      end

__________ file ./testinput

This is line 1
this is line 2
this is line 3
this is line 4
this is line 5



More information about the Comp.sys.sun mailing list