MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / proc_cmdline_getargv0

Function proc_cmdline_getargv0

cdb2api/cdb2api.c:359–381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

357#if defined(_SUN_SOURCE) || defined(_LINUX_SOURCE)
358
359static 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)

Callers

nothing calls this directly

Calls 1

sbuf2openreadFunction · 0.85

Tested by

no test coverage detected