[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::decc

Title:DECC
Notice:General DEC C discussions
Moderator:TLE::D_SMITHNTE
Created:Fri Nov 13 1992
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2212
Total number of notes:11045

1019.0. "execv and process permanent files ?" by MUNICH::KRAUTNER (Change mode to AXP) Wed Dec 07 1994 10:02

T.RTitleUserPersonal
Name
DateLines
1019.1RTL::COWANKen, TLGWed Dec 07 1994 11:0010
1019.2TLE::D_SMITHThu Mar 09 1995 12:106
1019.3again... should I be able to use "inherited" stderr?KZIN::HUDSONThat's what I thinkFri Mar 21 1997 10:5330
I'm not clear from reading the preceding notes whether propagation of
stderr from parent to child is meant to work or not.

I am using Alpha VMS 6.2, patch ALPACRT08_062 applied.  Using the program
in the basenote and a child program that looks like this

#include <stdio.h>
main()
{
	fprintf(stderr,"this is child writing to stderr\n");
	fprintf(stdout,"this is child writing to stdout\n");
}

I get the following output:

$ r parent

stderr is  SYS$ERROR:.;
--- got args:
speaxp$dka300:[hudson.fork]parent.exe;1
new stderr is SYS$SYSDEVICE:[HUDSON.FORK]OUT.LIS;1
execv a child:
              this is child writing to stderr
this is child writing to stdout
$ type out.lis
hello i'm an error
$


So, should this work?  Is another patch needed
1019.4entered into crtl internalTAVENG::BORISBoris Gubenko, ISESun Mar 23 1997 14:0128
>> So, should this work?  Is another patch needed

  It is supposed to work, but, both the "parent" program in the base note and
  the DEC C RTL should be fixed.

  As stated in the DEC C RTL Manual, the way the child process inherits the
  parent's open files is that the exec functions pass the file-name string
  associated with each file descriptor to the child and the child opens
  the file. In the example in .0 the parent did not specify RMS sharing option
  allowing the child to read and write the file and the child's open() failed
  with "RMS-E-FLK, file currently locked by another user" status. After this
  failure, the file descriptor associated with stderr remained uninitialized
  and the first attempt to write to stderr resulted in calling internal DEC
  C RTL routine opening stderr on the SYS$ERROR device.

  To fix this, the freopen() statement in the parent program must look like the
  following:

	freopen("out.lis","a",stderr,"ctx=rec","shr=get,put","rop=rea")

  Unfortunately, this is not enough. The DEC C RTL does passes among other
  things RMS sharing options specified by the parent to the child, but the
  the child fails to process them correctly.

  This is being tracked in crtl internal bug tracking system as problem
  number 1703.

  Boris