- Community Home
- >
- Servers and Operating Systems
- >
- Operating System - OpenVMS
- >
- Process mailbox usage simple question
-
- Forums
-
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Middle East
- HPE Blog, Latin America
- HPE Blog, Russia
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
-
Blogs
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Blog, Latin America
- HPE Blog, Middle East
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
-
Information
- Community
- Welcome
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Tips and Tricks
- Resources
- Announcements
- Email us
- Feedback
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Blogs
-
Information
-
English
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-18-2008 07:34 AM
11-18-2008 07:34 AM
I'm reading Mailbox SYS routines documentation
regard to synchronious I/O (to use standard I/O stream routines)
http://h30266.www3.hp.com/odl/vax/opsys/vmsos73/vmsos73/5841/5841pro_007.html
for example
and do not understand simple things.
I just translate 2 simple programs published at the doc from Fortran to C and wish it communicable
/* MAIN: */
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
main()
{
int stat_R0;
int mbx_chan;
FILE *M;
char s[1024];
$DESCRIPTOR( MBX_NAME, "MAIL_BOX" );
$DESCRIPTOR( SUBPROC, "RU SUBPROCESS.EXE");
stat_R0 = SYS$CREMBX (0,&mbx_chan,
NULL,NULL,NULL,NULL,
&MBX_NAME);
if((stat_R0 & 1) != 1)
LIB$SIGNAL(stat_R0);
if ( (M=fopen("MAIL_BOX","w+"))==NULL )
perror("cant fopen mailbox\n");
stat_R0 = LIB$SPAWN ( &SUBPROC );
fprintf(M,"hello\n ");
fgets(s,256,M);
if((stat_R0 & 1) != 1) perror("error spawn\n");
printf("%s\n",s);
}
/* SUBPROCESS */
#include
#include
#include
#include
#include
$DESCRIPTOR ( MBX, "MAIL_BOX" );
main()
{
int mbx_chan;
int stat_R0;
FILE *M;
char s[256];
stat_R0 = SYS$ASSIGN(&MBX,&mbx_chan,0,0);
if ( (stat_R0 & 1) != 1 )
perror("Error sys$assign\n");
if ( (M=fopen("MAIL_BOX","r+"))==NULL )
perror("get mailbox error\n");
fgets(s,255,M);
printf("read data: %s\n",s);
fprintf(M,"Answer: %s",s);
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-18-2008 07:38 AM
11-18-2008 07:38 AM
Re: Process mailbox usage simple question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-18-2008 08:40 AM - last edited on 04-11-2017 01:32 AM by VidyaVI
11-18-2008 08:40 AM - last edited on 04-11-2017 01:32 AM by VidyaVI
SolutionThere is no way I'd mix C standard I/O with mailboxes.
Can it work? Sure, but OpenVMS isn't Unix and everything isn't really streams of bytes on OpenVMS; trying to get C file semantics on RMS semantics on OpenVMS file semantics onto what are really mailbox devices tends to get, um, hairy.
Here's your example program, slightly rewritten:
[broken link removed on <4/11/2017> by Mod]
(there's a build procedure in the same directory.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-18-2008 09:30 AM
11-18-2008 09:30 AM
Re: Process mailbox usage simple question
int flags = CLI$M_NOWAIT;
...
stat_R0 = LIB$SPAWN ( &SUBPROC, NULL, NULL, &flags );
But I agree with Hoff that using standard C I/O with mailboxes is a bad idea. By default C I/O is stream oriented and mailboxes are record oriented and these don't mix well.
You might be able to get it to work by adding , "ctx=rec" to your FOPEN calls. If you do, then you don't need to SYS$ASSIGN a channel in the subprocess - that would only be needed if you were using SYS$QIOW call to read/write data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-18-2008 11:02 PM
11-18-2008 11:02 PM
Re: Process mailbox usage simple question
but can we discuss your example?
Ido not understand many things.
At MASTER mode you create mailbox named
"MBXNAM", right?
/*--- MASTER ----*/
$DESCRIPTOR( mbxnam_d, MBXNAM );
status = sys$crembx(0, &channel, MAXMBXMSG, MAXMBXBUF,
0, 0, &mbxnam_d, 0);
/* ------ */
Very good.
But for SLAVE process you opens SYS$INPUT,
attached to devnam_d that is not mailbox.
(I do not totally understand what value devnam_d is in your example, but it is a second question)
/* SLAVE */
$DESCRIPTOR( sysinp_d, "SYS$INPUT");
status = sys$assign( &sysinp_d, &channel, 0, 0, 0 );
/*--- */
Where you are reading from mailbox here ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-18-2008 11:18 PM
11-18-2008 11:18 PM
Re: Process mailbox usage simple question
I added flag you pointed.
when started, I just get string "hello"
on my terminal just like it simple typed by
printf("Hello");
I do not understand how it works. :(
It seems, so many years ago I was little yunger and clear :) (I am 33 now ) and could understand documentation. I had studed RT-11,TSX and P/OS on my Russian clone of Pro-350 17 years ago without any problems. And without Internet of course ;)
Documentation was clear for me. It seems I got a foolish for years for a distance from 1995 when I begun to study unix :) or documentation now from HP is not good as was from DEC.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-18-2008 11:51 PM
11-18-2008 11:51 PM
Re: Process mailbox usage simple question
the 'slave' process is being started with a $CREPRC system service, passing devnam_d as the SYS$INPUT file/device name. devnam_d is the descriptor for the devnam_b string, which contains the full device name of the mailbox obtained via a $GETDVIW call on the mailbox device channel.
Volker.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-19-2008 12:41 AM
11-19-2008 12:41 AM
Re: Process mailbox usage simple question
Ok, thank you.
now I understand a coupe of things...
It is interesting how MACRO concepts going to C. It is not clean sometimes ;) C is not best language for OpenVMS IMHO...
Found good thing:
http://www.openvms.compaq.com/openvms/journal/v9/mailboxes.pdf
I'm reading it...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-19-2008 02:35 AM
11-19-2008 02:35 AM
Re: Process mailbox usage simple question
page 12, Example 5
Another strange thing, strange behavor
This program should read strings from console and put into mailbox. And this is *screeshot* from the article:
-----------
$ r mailbox_writer
Bruce Ellis was here
Welcome to Mailboxes from BRUDEN-OSSG
We have lot's of great guys and a great Guy on board.
Control-Z was entered on the next line.
Exit
$
-----------
I've compiled sources from the acticle, but execution freezes during SYS$QIOW call
What's happens?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-19-2008 02:45 AM
11-19-2008 02:45 AM
Re: Process mailbox usage simple question
http://h71000.www7.hp.com/doc/732FINAL/aa-pv6sf-tk/aa-pv6sf-tk.HTMl
As some things have changed like stream I/O is now possible with mailboxes (although I don't know why).
Purely Personal Opinion
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2021 Hewlett Packard Enterprise Development LP