In Perl, is it possible to determine if a script is being executed within another script (presumably via system
or qx
)?
$ cat foo.pl
print "foo";
print "\n" if not $in_qx; # or the like.
I realize this is not applicable if the script was being run via exec
.
I know for certain that system
runs the process as a fork
and I know fork
can return a value that is variable depending on whether you are in the parent or the child process. Not certain about qx
.
Regardless, I'm not certain how to figure out if I'm in a fork
ed process without actually performing a fork
.