HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

equivalent of fork() in OpenVMS

 
naina
Occasional Visitor

equivalent of fork() in OpenVMS

I am writing a C code in OpenVMS.
I would like to know what how to create a child process in OpenVM.I suppose OpenVMS does not support fork().

Looking forward for your help....
4 REPLIES
Hoff
Honored Contributor

Re: equivalent of fork() in OpenVMS

There is no equivalent, or there is a direct equivalent.

Which of these two statements is true in your case depends entirely on what your code thinks fork() does.

Classic fork() isn't available, and classic fork does a whole lot more than most folks realize it does. This is less common.

The fork()/exec() model is available; see vfork() et al. This is the more common model, and use of fork() here can be replaced with vfork().

You'll want to read the C manuals as a start, as they're pretty good at describing this. And there are a couple of FAQs around for those that are familiar with C but are new to programming C on OpenVMS.

http://64.223.189.234/node/273

I will add a discussion of fork and vfork into that article, as I see I've omitted that.


Hein van den Heuvel
Honored Contributor

Re: equivalent of fork() in OpenVMS

What Hoff says...

Is this new code? Is there a portability requirement?

Why/What are you trying to fork?
Trying to get more threads?
or
Just trying to execute a (system) command?

OpenVMS offers alternative (and some times better) solutions for both, but it would have been nice to have a real fork with memory and file handle cloning and all.

Anyway... check out LIB$SPAWN when the call frequency is not crazy crazy (no more than once/second?)

And.. look around whether the task to be spawned is not available as a calleable service in the current image/process context.
OpenVMS has callable functions to find files, conver file, manipulates queue, get device information and on and on.

Welcome to OpenVMS and
Good Luck!
Hein.




Hoff
Honored Contributor

Re: equivalent of fork() in OpenVMS

If this is new code and not a port, then the other fairly widespread call used for creating a "child process" (usually a "subprocess" in OpenVMS terminology) is system(), BTW.

The system() call is the portable and mostly-analog version of lib$spawn or sys$creprc calls.

And while system() itself is portable C, the spawned command often isn't.

The fork() call is a subtle and extremely powerful call, and one best avoided. Unless you need its full magics, of course, and assuming you're on a box that has the full-power fork().
Heuser-Hofmann
Frequent Advisor

Re: equivalent of fork() in OpenVMS

There is a nice example in the "ask the wizard archive":

http://h71000.www7.hp.com/wizard/wiz_1274.html?jumpid=reg_R1002_USEN

Eberhard