[an error occurred while processing this directive]

HP OpenVMS Systems

ask the wizard
Content starts here

Programming with Mailboxes? (take II)

» close window

The Question is:

 
I am attempting to delete mailboxes I have created.  I use the following code
 in my attempt:
 
  char cmdmbxnam[]="CMD_MBX";
  char rspmbxnam[]="RSP_MBX";
  int status;
  short mbxchan;
$DESCRIPTOR(cmdmbxnamdsc,cmdmbxnam);
$DESCRIPTOR(rspmbxnamdsc,rspmbxnam);
 
  status = sys$assign(&cmdmbxnamdsc,&mbxchan,0,0);
  if ( status )
   {
    printf("CMD Mailbox assgnd! Channel = %d.  Status = %d.\n",mbxchan,status);
    status = sys$delmbx( mbxchan );
    if ( status ) printf("CMD Mailbox deleted!  Status = %d\n",status);
   }
 
  status = sys$assign(&rspmbxnamdsc,&mbxchan,0,0);
  if ( status )
   {
    printf("RSP Mailbox assgnd! Channel = %d.  Status = %d.\n",mbxchan,status);
    status = sys$delmbx( mbxchan );
    if ( status ) printf("RSP Mailbox deleted!  Status = %d\n",status);
 
When I run this code, I get:
 
 OPER> run really_delete_mbx
 CMD Mailbox assgnd! Channel = 192.  Status = 1.
 CMD Mailbox deleted!  Status = 1
 RSP Mailbox assgnd! Channel = 208.  Status = 1.
 RSP Mailbox deleted!  Status = 1
 
Yet if I display the logical name, CMD_MBX, or the associated MBX device,
 MBA1844, they are still there:
 
 OPER> sho log cmd_mbx
   "CMD_MBX" = "MBA1844:" (LNM$SYSTEM_TABLE)
 OPER> sho dev mba1844
 
Device                  Device           Error
 Name                   Status           Count
MBA1844:                Online               0
 
What am I doing wrong?
 
By the way, the command prompt is "OPER>" because at our site that is what
 happens when you set process privileges "SYSNAM" and "PRMMBX".
 
Thanks,
Ron
 
 
 
 


The Answer is :

 
  From the OpenVMS System Services Reference Manual:
 
  "The Delete Mailbox service marks a permanent mailbox for deletion.
  The actual deletion of the mailbox and of its associated logical
  name assignment occurs when no more I/O channels are assigned to
  the mailbox."
 
  For a temporary mailbox, the mailbox will be automatically deleted
  when the last channel to it is is deassigned.  (For this reason,
  the OpenVMS Wizard tends to prefer temporary mailboxes -- programs
  that are using temporary mailboxes need not explicitly execute
  clean-up code, and these programs also need not contend with any
  messages left in the (permanent) mailbox on program (re)start.)
 
  Also please see topics here in Ask The Wizard such as (5045) and
  (1661), and please the MBXDEMO* files found in the OpenVMS Freeware
  V4.0 directory SRH_EXAMPLES.
 

answer written or last revised on ( 29-MAY-2001 )

» close window