blob: ae39166f5a1af448e5cbec9fc77b22083d77116f [file] [log] [blame]
Juan Cespedes1fe93d51998-03-13 00:29:21 +01001#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 */
9char * 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}