HP3000-L Archives

June 2008, Week 4

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
"Walter J. Murray" <[log in to unmask]>
Reply To:
Walter J. Murray
Date:
Wed, 25 Jun 2008 20:59:19 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (84 lines)
Dan, 

Welcome to the -L!

Pay attention to Keven Miller's response.  The other posted responses
mostly miss the mark.

I'll just add a few comments.

The standard way to have a C program communicate its termination status
to the host environment is to specify a value on the return statement
from main().  Or call exit() with that value, which does the same thing.
See Keven's examples.

If you need only to communicate success or failure, there are two macros
defined specifically for that purpose.  They are declared in <stdlib.h>,
and they are named EXIT_SUCCESS and EXIT_FAILURE.  In HP C/iX, they have
the values 0 and 1, respectively.  

Here's some helpful text from the C/iX Reference Manual that directly
addresses your question:

"When an HP C/iX program terminates normally, a special job control
word, CJCW, is set to
the exit value of the program. It contains the value of the parameter
passed to the C
library routine exit, or _exit, or the value returned from the function
main if exit is not
explicitly called. The convention for C programs is to exit with a
nonzero value if an error
condition has occurred, or exit with zero if no errors have occurred.
CJCW could be used for
checking the exit value of a program in a job file, or programmatically
checking the exit
value of a child process. The value of CJCW is unpredictable if the
function main does not
take care to return a value or if the exit function is not explicitly
called."

One other point.  When using the CREATEPROCESS intrinsic, I have found
that typical practice is to have the child process begin execution right
away.  It is typically not necessary to call the ACTIVATE intrinsic
explicitly.  Depending on the parameters passed to CREATEPROCESS, the
parent process may suspend itself waiting to be reactivated when the
child terminates, or may continue executing concurrently with the child.

Old-timers will remember when we didn't have the CREATEPROCESS
intrinsic.  You had to explicitly call CREATE, then ACTIVATE.  

Again, welcome to 3000-L.  You'll find a lot of people here eager to
help.

Walter  

Walter J. Murray


-----Original Message-----
From: HP-3000 Systems Discussion [mailto:[log in to unmask]] On
Behalf Of Daniel Griffin
Sent: Wednesday, June 25, 2008 8:25 AM
To: [log in to unmask]
Subject: [HP3000-L] Return Codes from CREATEPROCESS

Hi all,

I just joined today and I have a question. I am attempting to use 
CREATEPROCESS to run other programs. How do I get return codes from 
whatever CREATEPROCESS runs(i.e. a C program)? I have looked at 
GETPROCINFO and PROCINFO and neither have been very useful. Can anyone 
point me in the right direction or tell me if this is even possible? Do 
return codes have the same meaning on MPE as they do on 
Linux/Windows/Solaris?


Thanks,
Dan

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2