| 357 | #if defined(_SUN_SOURCE) || defined(_LINUX_SOURCE) |
| 358 | |
| 359 | static char *proc_cmdline_getargv0(void) |
| 360 | { |
| 361 | char procname[64]; |
| 362 | static char argv0[PATH_MAX]; |
| 363 | |
| 364 | snprintf(procname, sizeof(procname), "/proc/self/cmdline"); |
| 365 | SBUF2 *s = sbuf2openread(procname); |
| 366 | if (s == NULL) { |
| 367 | fprintf(stderr, "%s cannot open %s, %s\n", __func__, procname, |
| 368 | strerror(errno)); |
| 369 | return NULL; |
| 370 | } |
| 371 | |
| 372 | if ((sbuf2gets(argv0, PATH_MAX, s)) < 0) { |
| 373 | fprintf(stderr, "%s error reading from %s, %s\n", __func__, procname, |
| 374 | strerror(errno)); |
| 375 | sbuf2close(s); |
| 376 | return NULL; |
| 377 | } |
| 378 | |
| 379 | sbuf2close(s); |
| 380 | return argv0; |
| 381 | } |
| 382 | #endif |
| 383 | |
| 384 | #if defined(_IBM_SOURCE) |
nothing calls this directly
no test coverage detected