How to get current process name in linux?

If you're on using a glibc, then:

#define _GNU_SOURCE
#include <errno.h>

extern char *program_invocation_name;
extern char *program_invocation_short_name;

See program_invocation_name(3)

Under most Unices, __progname is also defined by the libc. The sole portable way is to use argv[0]


It's either pointed to by the argv[0] or indeed you can read /proc/self/status. Or you can use getenv("_"), not sure who sets that and how reliable it is.