I believe you are asking why processes that are local spawned don't have the 
same pid as the spawning process?

With local-spawned processes, they share the same AS but they will still have 
different pid numbers.

One reason that child processes are not locally spawned is that they are 
started with fork + exec.  With fork, you always get a new AS.   The IBM shell 
(/bin/sh) will use spawn in some cases, and not in others. 

For example:

1)  cp vs /bin/cp   -  the latter is spawned, the former is a shell built-in 
which are never spawned.

2)  cmd1  | cmd2   - depends on the '-o pipecurrent' setting

3) x=`cmd xxx`  or x=$(cmd yyy)    - not spawned, which seems a pity.

If you want to test it more thoroughly, you will probably want to write some 
simple C programs that print getpid() getppid() and print the AS number.   It's 
also handy to write some code that uses spawn or spawnp.   

Kirk Wolf
Dovetailed Technologies
https://coztoolkit.com

PS> The best documentation on how things work is in the z/OS UNIX Assembler 
Programming guide.

On Tue, Feb 25, 2025, at 10:14 AM, Colin Paice wrote:
> I'm a it fuzzy about _BPX_SHAREAS=YES and if it is working (or not)
> 
> I have a shell script(s2) which prints out the pid, and parent pid.
> I call this from another script  s1.
> The output from
> _BPX_SHAREAS=YES sh s1
> _BPX_SHAREAS=NO sh s1
> Both print the same parent, so it looks like it is having no effect.
> 
> On the other hand when Zowe is started, I can see several address spaces
> start, run, and quickly end, and I want to make them run as shared and
> avoid this overhead.  Can I find out why a different address space was used?
> 
> The doc for BPX1SPN gives reasons why  _BPX_SHAREAS=YES is not honoured,
> including *If the program to be run is a set-user-ID or set-group-ID
> program that would cause the effective user-ID or group-ID of the child
> process to be different from that of the parent process.  *What is a
> "*set-user-ID
> program" *... and how does spawn know!
> 
> Am I missing something?
> 
> Colin
> 
> ----------------------------------------------------------------------
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to [email protected] with the message: INFO IBM-MAIN
> 

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to