I need to know which perl script is using my C CLI.
Using bash I can easily print “who” ran a script using:
CALLER=$(ps ax | grep "^ *$PPID" | awk '{print $NF}')
echo $CALLER
Up to now I have been using this as a wrapper but it’s not ideal. Is there a way to get this information from within C?
(I’m running UNIX w/ gcc)
You should look at
getpidandgetppidfunctions from<unistd.h>.