#!/bin/sh # Copyright (C) 2006-01-14 Paul Sladen. GNU GPL for you. # Guess the Debian source package of a running process number. PID="$1" ; PROC="/proc/$PID" test "$PID" -eq "0$PID" -a -d "$PROC" 2>/dev/null || exit 10 EXECUTABLE=$(readlink -f "$PROC/exe" || grep -azm1 '^/' "$PROC/cmdline" || which $(grep -azm1 . "$PROC/cmdline" | cut -d' ' -f1)) test $? -ne 0 && exit 20 PACKAGE=$((/usr/bin/dpkg -S "$EXECUTABLE" 2>/dev/null || exit 1) | cut -d: -f1 ) test $? -ne 0 && exit 30 SOURCE=$(/usr/bin/apt-cache show "$PACKAGE" | awk '/^(Package|Source):/{print$2}' | tail -1) echo PID=$PID EXECUTABLE=$EXECUTABLE PACKAGE=$PACKAGE SOURCE=$SOURCE