in reply to -n and -p suck up ARGV no matter what
With Perl, you can simply use getppid(), but since this isn't perl, you can use this:
ps -o ppid= -p $pid [download]
...and that should get you your parent PID without having to use Perl, sed etc.