Juan Cespedes | 1fe93d5 | 1998-03-13 00:29:21 +0100 | [diff] [blame^] | 1 | #include <sys/types.h> |
2 | #include <stdio.h> | ||||
3 | #include <string.h> | ||||
4 | #include <signal.h> | ||||
5 | |||||
6 | /* | ||||
7 | * Returns a file name corresponding to a running pid | ||||
8 | */ | ||||
9 | char * pid2name(pid_t pid) | ||||
10 | { | ||||
11 | char proc_exe[1024]; | ||||
12 | |||||
13 | if (!kill(pid, 0)) { | ||||
14 | sprintf(proc_exe, "/proc/%d/exe", pid); | ||||
15 | return strdup(proc_exe); | ||||
16 | } else { | ||||
17 | return NULL; | ||||
18 | } | ||||
19 | } |