Operating System - OpenVMS
1827443 Members
6186 Online
109965 Solutions
New Discussion

Passing process logical to spawned process

 
SOLVED
Go to solution
P R Stone_1
Advisor

Passing process logical to spawned process

I have a system that works when it runs as part of a cgi script through Apache but not when it runs as part of a batch job.

IN APACHE

Cgi-script

RUN xxxx
xxx will set process logicals and spawn (using defaults) RUN yyy.
yyy will read process logicals and can spawn RUN zzz.
zzz will read process logicals and do work.

Runs successfully - all programs can read the process logicals.


IN BATCH

RUN xxx
xxx will set process logicals and spawn (using defaults) RUN yyy.
yyy will read process logicals and can spawn RUN zzz.
zzz will read process logicals and do work.

SHOW logicals/process displays logicals correctly set by xxx

Neither yyy nor zzz can see the process logicals set by xxx.

All quotas are set high enough that they should not have any effect and are similar for both the Apache and Batch jobs.

As I understand it a spawn should by default copy its process logicals from the parent to the child.

Why are the process logicals not being passed within the batch process?
16 REPLIES 16
Volker Halle
Honored Contributor

Re: Passing process logical to spawned process

P R,

I've tested this with a couple of DCL procedures and it seems to work for me - interactively and in batch.

Please test this on your system.

Proc_1: defines level_0 logical and spawns @proc_2

proc_2: defines level_1 logical and spawns @proc_3

proc_3: show level_0 and level_1 logical

The LIB$SPAWN RTL routine has a flags argument, in which the NOLOGNAM bit could prevent logical names to be passed to the spawned (child) process. Same as /NOLOGNAM qualifier used with the SPAWN DCL command. The default is to pass process logicals to the spawned subprocess.

Volker.
Uwe Zessin
Honored Contributor

Re: Passing process logical to spawned process

A batch job is a process that does a complete new login. It is started by the job controller, not the user's process - the user could have logged out a long time ago or did the SUBMIT on a different cluster member or even done a SUBMIT/REMOTE via DECnet.
.
Uwe Zessin
Honored Contributor

Re: Passing process logical to spawned process

Ah, seeing Volker's response it looks like I have misunderstood your question, sorry.
.
P R Stone_1
Advisor

Re: Passing process logical to spawned process

I have run the test as Volker suggested and it works for me. This implies that the problem is with program xxx and its spawn RUN yyy.

However it works as part of the cgi-script which suggests that the code is okay but there is a problem with the configuration / environment.

Petr Spisek
Regular Advisor

Re: Passing process logical to spawned process

If you want to use logical name for more processes, you need to define this as the system logical (rather DEFINE/SYSTEM/EXEC)
Petr
Volker Halle
Honored Contributor

Re: Passing process logical to spawned process

Petr,

for a logical to be visible for all processes in a job tree (parent and spawned processes), it's sufficient to use DEFINE/JOB - DEFINE/SYSTEM/EXEC may be a bit of an over-kill.

Volker.
Petr Spisek
Regular Advisor

Re: Passing process logical to spawned process

:-)
Thanks for correction, it's true - DEFINE/JOB is realy sufficient.
Petr
P R Stone_1
Advisor

Re: Passing process logical to spawned process

I have tried job logicals and the following works:

RUN xxx
xxx will set job logicals and spawn @yyy
yyy (in DCL) will read job logicals and set process logicals and RUN zzz


It works but is a real hack and does not answer the underlying problem.


I need to use process logicals as that is the table zzz reads from, also I can' change it (program zzz is effectively an exe only).
I can change program xxx and yyy.
Volker Halle
Honored Contributor

Re: Passing process logical to spawned process

P R,

so XXX, when run in batch mode, will not copy its process logicals to the spawned subprocess, right ?

Do you use the flags argument in the call to LIB$SPAWN - 4th argument ?

This should be the only variable being able to influence this behaviour.

Volker.
P R Stone_1
Advisor

Re: Passing process logical to spawned process

My spawn commmand is a BASIC function

status_flag = TRUE

stat = lib$spawn(p_command)
IF stat<>SS$_NORMAL THEN
status_flag = FALSE
END IF

! Set return value
! ----------------
fgi_spawn = status_flag


I have tried lib$spawn(p_command,,,0) but it makes no difference
Volker Halle
Honored Contributor

Re: Passing process logical to spawned process

P R,

I've tried the following simple BASIC program TEST.BAS:

call lib$spawn('SHOW LOG/PROC')
end

Create a .COM procedure:

$ DEFINE/PROCESS ABC test
$ RUN test

And run it interactively or in batch. The ABC logical is printed in both cases (tested on OpenVMS Alpha V7.2-1) and I don't expect it to behave any different on any other version of OpenVMS.

Volker.
Petr Spisek
Regular Advisor

Re: Passing process logical to spawned process

Did you fix up that your batch process terinate after its subprocesses?
For example: F$GETJPI("","PRCCNT")
Petr
Wim Van den Wyngaert
Honored Contributor

Re: Passing process logical to spawned process

Help spawn/logicals.

Exec and kernel mode are not copied. Also the /name=confine logicals are not copied.

Is your login defining them differently according to the mode (I/B/O) ?

In batch, did you check if the logicals are visible by xxx ? I'm thinking of IFs in your login.com.

Wim
Wim
Chinraj Rajasekaran
Frequent Advisor
Solution

Re: Passing process logical to spawned process

Hi,

SPAWN command...

By default, all process logical names and logical name tables are copied to the subprocess except those explicitly marked CONFINE or created in executive or kernel mode.

------------------------------

If the Batch jobs is submitted under different user account than the CGI script user and batch jobs doesn't work well as expected , then there must be user level privilege difference.

Note that you must have SYSNAM or SYSPRV privileges to create logical names in executive mode in any logical name table.

When you use the DEFINE command without specifying a mode, DCL creates the logical name in supervisor mode.

----------------------------

regards
Raj
P R Stone_1
Advisor

Re: Passing process logical to spawned process

My batch process was running under a different mode to the apache job. This was the cause of the problem.
The solution was to pass job logicals into spawned DCL and copy them to process logicals to run the required exe.
Better solutions can be imagined and will be implemented when time allows.
P R Stone_1
Advisor

Re: Passing process logical to spawned process

See previous comment