Thanks for the insights.
I do find the behaviour borderline nuts presuming different rules for coercing variables.
An arguably valid definition I can think of as an alternate is that "$$" is by definition the initial shell's PID as opposed to the current process's PID, independent of sub-shells much like PPID is the parent of the initial shell regardless of being in a sub-shell or not. This is consistent with a few ksh man pages I dug up though not obvious.
It also seems to be consistent with a few experiments I tried with "eval" with a composite string that results in "$$" which would preclude the initial parsing of the (....)& from coercing a manifest $$ and that also produced the same result.
That ksh treats a subshell differently from a forked instance of ksh is consistent with other aspects of behaviour (e.g. variables need not be exported to be seen by a sub-shell) but it sure messes up the notion of using inline code vs external scripts in any consistent manner.
I will derive an alternative strategy (messing with ps -ef is not an option because my code needs to run under Solaris and Windows/MKS wherein ps differs due to the information about process parameters maintained by Windows).
Thanks again.
Michel
|