From:	MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX" 16-JUL-1992 22:14:16.74
To:	info-vax@kl.sri.com
CC:	
Subj:	shared read access via rab/fab & sys$create()

I posted an earlier article concerning trying to open a file in VAXC with
the shareable read attribute. At that time I tried using the optional parameter
in fopen() to pass these attributes.  Seeing that fail, I decided to use 
sys$open( &fab ) & do it myself (or as much as possible from a higher level
language other than macro32).  I use the below segment of code in a routine to 
open the file.  The body of my test main() is based on:
  open_file("test_file.dat");
  while (1)
  {
	put_rec(&record);
	sleep(10);
  }

However, while this program is running, I still can't do 'type test_file.dat' 
from a different window (process). I get the ol' -RMS-E-FLK, file currently 
locked by another user.
-- what am I missing that will enable me to allow other processes to read the
output of the file while still opened via the code below?  
Thanks for your help.
-steve
[ note from later: problem is he was using DFS disks. Code here works ok
  on local disks.]
-----------------

#include <stdio.h>
#include <time.h>
#include <rms.h>
#include <ssdef.h>

static  struct FAB log_fab;
static  struct RAB log_rab;
static	char  output_str[200];
...
...

    log_fab = cc$rms_fab;	/* init the FAB */
    log_fab.fab$b_fac = FAB$M_PUT;
    log_fab.fab$l_fna = "ce_cmd_log";
    log_fab.fab$b_fns = strlen( "ce_cmd_log");
    log_fab.fab$l_fop |= FAB$M_SQO;
    log_fab.fab$b_org = FAB$C_SEQ;
    log_fab.fab$b_rat = 0;
    log_fab.fab$b_rfm = FAB$C_STMLF;
    log_fab.fab$b_shr = FAB$M_SHRGET;

    log_rab = cc$rms_rab;
    log_rab.rab$l_fab = &log_fab;
    log_rab.rab$b_rac = RAB$C_SEQ;

    rms_stat = sys$create( &log_fab, 0, 0 );
    if ( rms_stat != RMS$_NORMAL && rms_stat != RMS$_CREATED )
    {
	fprintf(stderr, "error opening ce_cmd_log for writing\n" );
	log_open = 0;
	return( 0 );
    }
    rms_stat = sys$connect( &log_rab, 0, 0 );
    if ( rms_stat != RMS$_NORMAL )
    {
	fprintf(stderr, "error opening ce_cmd_log via sys$connect()\n" );
	log_open = 0;
	return( 0 );
    }
    log_open = 1;
    return( 1 );

------------------------------------------------------------------------------
Steve Hespelt - Laboratory for Laser Energetics University of Rochester
                250 East River Rd. Rochester, NY  14623
fooz@lle.rochester.edu                                    (716) 275-5280
fooz@max.db1.cc.rochester.edu    _________________\|/_    Fax (716) 275-5960
                                                  /|\

