# z/OS: with _BPX_SHAREAS=YES a spawned child shares the shell's address # space; with NO it gets its own. xasid is the ps(1) address space id. # Look at a live /bin/sleep rather than asking /bin/sh to run ps: /bin/sh # has the sticky bit on z/OS, and spawn() is required to give such a file # its own address space regardless of _BPX_SHAREAS. # spawn() returns before the child is visible to ps, so look for it a few # times; a system that never shows it cannot be measured here at all. asid_of() { tries=0 while [ "$tries" -lt 5 ]; do a=$(ps -o xasid= -p "$1" 2>/dev/null | tr -d ' ') [ -n "$a" ] && { echo "$a" return } tries=$((tries + 1)) /bin/sleep 1 done } me=$(asid_of $$) [ -n "$me" ] || exit 77 _BPX_SHAREAS=YES; export _BPX_SHAREAS /bin/sleep 3 & child=$! shared=$(asid_of "$child") wait "$child" [ -n "$shared" ] || exit 77 [ "$shared" = "$me" ] && echo "YES: same address space" || echo "YES: different ($me $shared)" _BPX_SHAREAS=NO /bin/sleep 3 & child=$! own=$(asid_of "$child") wait "$child" [ -n "$own" ] || exit 77 [ "$own" != "$me" ] && echo "NO: own address space" || echo "NO: shared" # A subshell is a fork(): always its own address space. child=$( /bin/sleep 3 & p=$! asid_of "$p" wait "$p" ) [ -n "$child" ] || exit 77 [ "$child" != "$me" ] && echo "fork: own address space" || echo "fork: shared"