How to get one's current process ID (pid) from Linux cmdline (in shell- and language-independent fashion)? pidof(8) appears to have no option to get the calling-processes pid. bash of course has
Example session with both methods (along with other proposed, non-working methods) shown here.
(Not sure how pertinent/useful it is to be so concerned with being shell independent, but have simply experienced many times the "run system call without shell" constraint that now seek shell-independent options whenever possible.)