Operating System - OpenVMS
1752492 Members
5255 Online
108788 Solutions
New Discussion юеВ

Re: submitting a job to a batch queue from a detached process

 
Larry_139
Occasional Contributor

submitting a job to a batch queue from a detached process

I've tried different variations of trying to start/stop processes from a batch file via the loginout.exe

for example using lib$spawn & sys$creprc from a 'c' prog - to no avail

Is this possible & if so any help pointing me in the correct direction would be appreciated.

Thanks in Advance

7 REPLIES 7
Hein van den Heuvel
Honored Contributor

Re: submitting a job to a batch queue from a detached process

I'm sorry, but I am really confused about your subject content vs message content, maybe others also?

Submitting a job to a batch queue, as requested per your subject line, is done by sending a message to the jobcontroller through a call to SYS$SNDJBC. Documented in http://h71000.www7.hp.com/doc/82FINAL/4527/4527pro_109.html#jun_547

lib$spawn creates a sub-process, and sys$creprc can be used the create a detach process.
Hints:
- check out the sys$input ands sys$output expectation
- check out the 'login.com' context expect, which is not there for a detached jobn unless you run loginout.exe first.

What is the error message you get? You are checking/reporting the status right?

Maybe SHOW ACCOU/FULL/SINCE=... can tell you why jobs failed?

Hope this helps some,
Hein.
David B Sneddon
Honored Contributor

Re: submitting a job to a batch queue from a detached process

Larry,

Can you provide some sample code and details
of what status values are returned from the
calls to lib$spawn and sys$creprc?
We use this method a lot here and have no problems.

Regards
Dave
Robert Gezelter
Honored Contributor

Re: submitting a job to a batch queue from a detached process

Larry,

Let's go back a step. What exactly are you trying to accomplish? The important question is not "How I fix X (technique)?" but "What is the best way to implement X (function)?".

- Bob Gezelter, http://www.rlgsc.com
Larry_139
Occasional Contributor

Re: submitting a job to a batch queue from a detached process

Sorry that my email is not as clear as it needs to be - I'm relatively a greenie at a bunch of this.

Originally I was trying to kill and existing process and restart it if certain conditions were met.

I tried to stop & restart via the lib$spawn - passing 'stop myprocess' & 'run /detached /process_name=myprocess dka100:[common.mydir]myprocess' thru the descriptor.

Then I tried to the same thru sys$creprc.

My next attempt was to start a batch file that would stop / restart the process. (Thought that would work by using the loginout.exe, after reviewing docs that indicated the detached process needed a CLI).

So... What I'm really trying to do is start / stop a detached process from a detached process.

Hope this make more sense.. Thanks again from a newbie....







David B Sneddon
Honored Contributor

Re: submitting a job to a batch queue from a detached process

Hi Larry,

Some sample code would make it easier, along with details of status
values returned.

Here is some (BASIC) code used here:
(formatting will be awful)

stsflg = prc$m_detach
sstatus = sys$creprc (creprc_pid by ref,
loginout by desc, control_file by desc, file_sys$output by desc, file_sys$error by desc,,, process_name by desc, priority by value,,, stsflg by value)

With appropriate values for each of the variables.

For killing processes, we use sys$delprc.

Since you are using C, do you have the string descriptor
stuff handled correctly?

Regards
Dave
Hein van den Heuvel
Honored Contributor

Re: submitting a job to a batch queue from a detached process


Actually, before we $DELPRC we like to see a $FORCEX, to give teh process a change for image rundown.
Check the system service ref manual, or inititally just '$HELP SYSTEM $FORCE'

Do you have control over the detached procecss code? Why not build in a clean, async exit? Maybe a (common) event flag, or lock poll in a central loop. Maybe an async entry point through a mailbox-attention-ast, or a lock blocking ast, or whateevr inter process communication technique you are used to.


Also... what problem are you really trying to solve?
Why do you know the process needs to be stopped and restarted? Can the process itself determine that somethign needs to be done? Like if it had a know, 'unavoidable' memory leak, could check check?
Or if you need a fresh log file, why not have it close the current and re-open the next withough stop/start?

hth,
Hein.
Jan van den Ende
Honored Contributor

Re: submitting a job to a batch queue from a detached process

Larry,

Let me try to get this exact:


tried to stop & restart via the lib$spawn - passing 'stop myprocess' & 'run /detached /process_name=myprocess dka100:[common.mydir]myprocess' thru the descriptor.

Then I tried to the same thru sys$creprc.


At least for the first try (spawn) I understand what happened:
- you spawn a supprocess.
- the supprocess kills the main process.
---- as as result thereoff, all subprocesses of the main process are killed, including the just-spawned.
- the supprocess never reaches the point where it can run another process, because it is killed before it can execute that command.

Trying "the same" thru sys$creprc...
How exactly is that "the same"? Are you again killing yourself (directly or indirectly) before intending to create a new process?

I think the wise thing to do is Hein's advice:
"What are you trying to achieve? And why?"
If you post that here, let's see what the crowd comes up with.

I tend to go with Hein that that might well lead to totally other ways to go that have much better chances of succeeding.

Proost.

Have one on me.

Jan
Don't rust yours pelled jacker to fine doll missed aches.