home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / os / vms / 21798 < prev    next >
Encoding:
Internet Message Format  |  1993-01-23  |  8.0 KB

  1. Path: sparky!uunet!elroy.jpl.nasa.gov!nntp-server.caltech.edu!SOL1.GPS.CALTECH.EDU!CARL
  2. From: carl@SOL1.GPS.CALTECH.EDU (Carl J Lydick)
  3. Newsgroups: comp.os.vms
  4. Subject: Re: mailboxes with DCL?
  5. Date: 23 Jan 1993 00:19:48 GMT
  6. Organization: HST Wide Field/Planetary Camera
  7. Lines: 161
  8. Distribution: world
  9. Message-ID: <1jq2v4INNhrv@gap.caltech.edu>
  10. References: <1993Jan21.032056.373@wega.rz.uni-ulm.de> <1joq6oINN32k@gap.caltech.edu>,<22JAN199315351392@robot.nuceng.ufl.edu>
  11. Reply-To: carl@SOL1.GPS.CALTECH.EDU
  12. NNTP-Posting-Host: sol1.gps.caltech.edu
  13.  
  14. In article <22JAN199315351392@robot.nuceng.ufl.edu>, sysop@robot.nuceng.ufl.edu (Shawn A. Clifford) writes:
  15. >>You can't create mailboxes from DCL.  You've got to write a program to create
  16. >>them (and, since you're probably restricted to creating temporary mailboxes,
  17. >>they go away, by default, at image rundown).  What you need to do is:
  18. >
  19. >Not  necessarily.  If you post a read to the mailbox, the mailbox lives after
  20. >the program exits.  For an example of this, look in PUBLIC$:[DCL] at
  21. >robot.nuceng.ufl.edu for the obvious files.
  22.  
  23. I just looked.  You shouldn've have contradicted me.  I'm the author of both
  24. the LIFEMBX and the PAGINATE programs.  I wrote them back in the mid-80s when I
  25. was managing a system called CITHEX for the high energy physics people here at
  26. Caltech.  You're wrong.  It's not the fact that the program issued a READ on
  27. the mailbox before exiting that keeps the mailbox around.  It's the fact that
  28. the parent process has OPENed the mailbox.  In fact, the LIFEMBX.C and
  29. LIFEMBX.COM files you reffered to are an implementation of exactly the strategy
  30. I outlined and you deleted in your response:
  31.     1)  Spawn a subprocess which runs an executable which:
  32.         A)  Uses $CREMBX to create a temporary mailbox;
  33.         B)  Issues a (synchronous) READ on the mailbox;
  34.         C)  Exits after the read completes;
  35.     2)  From the parent process,
  36.         A)  Use the DCL OPEN command to assign a channel to the mailbox;
  37.         B)  Use the WRITE command to write a record to the mailbox.
  38. So the sequence of actions is:
  39.     1)  Parent spawns subprocess;
  40.     2)  Subprocess creates mailbox;
  41.     3*) Subprocess issues READ on mailbox;
  42.     4*) Parent process OPENs mailbox;
  43.     5*) Parent process WRITEs to mailbox;
  44.     6)  Subprocess's READ completes;
  45.     7)  Subprocess exits.
  46. Note:  Step 3 can occur either between steps 2 and 4, between steps 4 and 5, or
  47. between steps 5 and 6.
  48.  
  49. >One for creating the mailbox in a high level language,
  50.  
  51. Correct.
  52.  
  53. >one for defining the mailbox logical and buffer size as a startup for other
  54. >routines written in DCL,
  55.  
  56. Incorrect.  Take another look at LIFEMBX.COM:
  57.  
  58.     $! LIFEMBX.COM -- create a semi-permanent mailbox, with an entry
  59.     $!                     for it in the job logical name table
  60.     $! Copyright (C) 1986, The Caltech Odd Hack Committee, no rights reserved
  61.     $ verify = 'f$verify(0)'
  62.     $ on error then goto fail
  63.     $ on control_y then goto fin
  64.     $ _status = 1
  65.     $ if p1 .eqs. ""
  66.     $ then
  67.     $     write SYS$ERROR "Usage: @lifembx [size] name [size2]"
  68.     $    goto fail
  69.     $ endif
  70.     $ if p2 .eqs. "" then p2 = p1
  71.     $ if p2 .eqs. p1 then p1 = 132
  72.     $ if p3 .eqs. "" then p3 = p1
  73.     $ lifembx = f$search("TOOLS:lifembx.exe")
  74.     $ if lifembx .eqs. ""
  75.     $ then
  76.     $    write SYS$ERROR "Can't find TOOLS:lifembx.exe"
  77.     $     goto fail
  78.     $ endif
  79.     $ spawn/nowait/nolog/nosym/nokey/nologi mcr 'lifembx' 'p1' 'p2' 'p3'
  80.  
  81. Note:  This is *NOT* "defining the mailbox logical and buffer size as a startup
  82. for other routines written in DCL."  This is simply taking the mailbox logical
  83. name SPECIFIED BY THE USER and either taking user-specified values for the
  84. "maxmsg" and "bufquo" arguments to $CREMBX or using a default value of 132
  85. characters for both.
  86.     $wait:    wait 00:00:01.0
  87.     $ open/read/write/share=write/err=wait TMPFILE 'p2':
  88. In this loop, the parent process waits until the mailbox is created.  I really
  89. should've put a counter in this loop;  if the subprocess fails to create the
  90. mailbox, then the parent goes into an infinite loop.  No real problem if you're
  91. doing this from a terminal, since it'll quickly become obvious that you're in a
  92. loop, and a control-Y will get you out of it, but if you execute this procedure
  93. in a batch job, the job hangs until killed.  So you really ought to change
  94. those lines to:
  95.     $    loopcount = 0
  96.     $ wait:    wait 00:00:01.00
  97.     $    if loopcount .ge. 30 then goto fail
  98.     $    loopcount = loopcount + 1
  99.     $    open/read/write/share=write/err=wait TMPFILE 'p2':
  100. This way, the procedure will fail after 30 seconds if no mailbox has been
  101. created.  If the open succeeds, then we've got a channel assigned to the
  102. mailbox by the parent process.  This means that the mailbox will stick around
  103. when the LIFEMBX image running in the subprocess deassigns its channel to the
  104. mailbox and exits.
  105.  
  106.     $    write TMPFILE ""
  107.  
  108. This WRITE satisfies the READ on the mailbox issued by the subprocess, allowing
  109. the subprocess to deassign its channel to the mailbox, exit from the image, and
  110. then exit.
  111.  
  112.     $ deassign TMPFILE
  113.  
  114. This is to prevent you from accidentally CLOSEing  TMPFILE, which would make
  115. the mailbox go away.
  116.  
  117.     $ goto fin
  118.     $fail:
  119.     $ _status = 2
  120.     $fin:
  121.     $ exit _status + 0*f$verify(verify)
  122.  
  123. So what the file LIFEMBX.COM is really doing is:  Spawning a subprocess to run
  124. the image to create the mailbox, then assigning a channel to it from the parent
  125. process, issuing a write to the mailbox to allow the subprocess to exit, and
  126. then DEASSIGNing the logical name associated with the channel, so that the
  127. mailbox can't be accidentally deleted.
  128.  
  129. If you want to be able to delete the mailbox, you should remove the command:
  130.  
  131.     $ deassign TMPFILE
  132.  
  133. from the procedure.  Then you can delete the mailbox via the command:
  134.     $    CLOSE TMPFILE
  135. If you HAVE DEASSIGNed the logical name TMPFILE, then you'll have to use a
  136. program that uses $DASSGN to deassign the channel associated with the mailbox.
  137. Even finding the channel number take privs (or perhaps just a detailed
  138. knowledge of VMS internals;  I always find the channel numbers associated with
  139. processes via the ANALYZE/SYSTEM command), so if you plan to delete the mailbox
  140. (other than by logging out the process from which you issued the @LIFEMBX
  141. command), you really SHOULD comment out the DEASSIGN command.
  142.  
  143.  
  144. >and a DCL comfile that makes use of mailboxes by paging output from any other
  145. >program to your screen
  146.  
  147. PAGINATE.COM does this by using LIFEMBX to create a 132-character-wide mailbox
  148. called PAGEPIPE (unless the logial name PAGEPIPE already exists), then treating
  149. its command-line arguments as a command to be spawned.  It spawns that command,
  150. then TYPE/PAGEs PAGEPIPE.  After you exit from TYPE, PAGINATE:
  151.     1)  Attempts to STOP the subprocess it created (in case you exited from
  152.         the TYPE command before reading everything the subprocess wanted to
  153.         output;
  154.     2)  OPENs PAGEPIPE for read;
  155.     3)  READs from PAGEPIPE until it reaches and end-of-file or a timeout;
  156.     4)  CLOSEs PAGEPIPE
  157. thus cleaning up after itself.  Actually, I wrote LIFEMBX and PAGINATE mainly
  158. in order to be able to TYPE/PAGE the output of a DUMP command without having to
  159. set my terminal to 132 character width.  DUMP bases the format of its output on
  160. the buffer size of the output device.  When it dumps to a terminal, this means
  161. it bases it on the current terminal width.  When it dumps to a disk file, it
  162. sees a buffer size of 512 bytes, and uses its widest output format.  When it
  163. sees a mailbox, it sees a buffer size equal to the value specified in "maxmsg"
  164. when the mailbox was created.  Thus, you can use LIFEMBX to create the mailbox
  165. PAGEPIPE with a maxmsg of 80, then use PAGINATE to TYPE/PAGE the output from
  166. the DUMP command on an 80-character-wide screen.
  167. --------------------------------------------------------------------------------
  168. Carl J Lydick | INTERnet: CARL@SOL1.GPS.CALTECH.EDU | NSI/HEPnet: SOL1::CARL
  169.  
  170. Disclaimer:  Hey, I understand VAXen and VMS.  That's what I get paid for.  My
  171. understanding of astronomy is purely at the amateur level (or below).  So
  172. unless what I'm saying is directly related to VAX/VMS, don't hold me or my
  173. organization responsible for it.  If it IS related to VAX/VMS, you can try to
  174. hold me responsible for it, but my organization had nothing to do with it.
  175.