| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
#if defined(_AIX) |
| 11 |
#include <stdio.h> |
| 12 |
#include <sys/procfs.h> |
| 13 |
#include <unistd.h> |
| 14 |
#include <fcntl.h> |
| 15 |
#include <errno.h> |
| 16 |
#include <string.h> |
| 17 |
|
| 18 |
|
| 19 |
char program_invocation_short_name[256 + 1] = { NULL, }; |
| 20 |
|
| 21 |
void populate_progname(void) { |
| 22 |
struct psinfo ps; |
| 23 |
int psfd; |
| 24 |
|
| 25 |
snprintf(program_invocation_short_name, 256, "/proc/%lld/psinfo", getpid()); |
| 26 |
psfd = open(program_invocation_short_name, O_RDONLY); |
| 27 |
if (psfd == -1) { |
| 28 |
fprintf(stderr, |
| 29 |
"Failed to open procfs to read cmdname: %s\n", strerror(errno)); |
| 30 |
return; |
| 31 |
} |
| 32 |
|
| 33 |
if (read(psfd, &ps, sizeof(ps)) == -1) { |
| 34 |
fprintf(stderr, "Failed to populate psinfo: %s\n", strerror(errno)); |
| 35 |
return; |
| 36 |
} |
| 37 |
close(psfd); |
| 38 |
strncpy(program_invocation_short_name, ps.pr_fname, PRFNSZ); |
| 39 |
} |
| 40 |
#endif |