Embarassed to ask - Regina & Fork

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Embarassed to ask - Regina & Fork

Kevin Kinney
I've used Rexx on the big box for many years.  I'm dipping into Regina on Linux and need to fork a process.
I've found the documentation.  It's embarrassingly simple, as are any examples.

And yet I still can't figure it out.

Can someone provide a Regina 'fork' example that's longer than one stupid line?

Thank you,
kk
Reply | Threaded
Open this post in threaded view
|

Re: Embarassed to ask - Regina & Fork

Chris
Hi, I see this is a year old, but in case you didn't get an answer, there is a slide in this presentation:
http://www.rexxla.org/events/2015/presentations/REXXLAUW2015.pdf
The slide entitled "Process Modeling" was enough to get me going.

I have just started this myself, but my code looks like this:
pid = fork()                               /* This does NOT work on Windows */
if pid >0 then do
   call on halt name nohalt
   say "In the child process"
end

else do
   signal on halt
   say "In the parent process"
end
...

Somehow both end up getting run. I have two different CTRL-C handlers because CTRL-C will be seen by both. Note that fork(), at least the version of Regina I run, does NOT work on Windows (always returns '1' which is reported in the doc to indicate "not available").  I've also found that both the parent and child need to flow out to a common endpoint (i.e., no returns or exits in one branch vs. the other).