Skip to content

get_ppid 2 is not 1 #572

Description

@antalk2

get_ppid() { # get ppid of pid $1

get_ppid 2 returns a large number. I guess it sums the ppids of all pids containing 2

Possible replacement:

get_ppid() {
    local pid_to_check="${1:empty_pid}"
    local res=''
    res="$( $Myps ax -o pid,ppid                  \
           | grep -E '^\s+'"${pid_to_check}"'\s+' \
           | awk ' { print $2 } '
         )"
    if [ -z "$res" ] ; then
        echo "" # what should be printed here?
        return 1
    else
        echo "$res"
        return 0
    fi
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions