[comp.sys.sun] Problem with Fortan system

jon@astro.ucla.edu (Jonathan Eisenhamer) (03/11/89)

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@astro.ucla.edu
	jon@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

schwartz@shire.cs.psu.edu (Scott Schwartz) (03/30/89)

jon@astro (Jonathan Eisenhamer) writes:
>Is this a known bug with system(3F)? or is this a "feature"?  This is
>under 3.5SunOs.

It works correctly under 4.0+.  
-- 
Scott Schwartz		<schwartz@shire.cs.psu.edu>

TS46@DFVLRGO1.BITNET (04/04/89)

> A problem has been noted with the procedure system(3F) in fortran.
> ...all opened files are truncated as soon as a call to system(3F) is made.

This is definitively a bug. I had the same problem earlier. SUNOS 3.4 and
3.5. (don't know about earlier releases)

B.Walter
german aerospace research establishment DLR
TS46.dfvlrgo1.bitnet

zjat02@uunet.uu.net (Jon A. Tankersley) (04/22/89)

Ahhh.. But there are other problems with system under 4.x fortran.  They
have a patch available for it.

-tank-
#include <std/disclaimer.h>		/* nobody knows the trouble I .... */