Saturday, 8 June 2013

how to know process pid of bash function running as child?

how to know process pid of bash function running as child?

I am trying to know the pid of a function that was run as child process on a script
FUNCtstPsSelf.sh
#!/bin/bash
echo "pid=$$;ppid=$PPID"
ps -p $$
function FUNCtstPsSelf() {
    sleep 3;
    echo "$FUNCNAME:pid=$$;ppid=$PPID";
    ps -p $$ -o pid,ppid,command;
}
FUNCtstPsSelf&
sleep 1;
but it can't find the pid! what now?

No comments:

Post a Comment