Commit 489977f7 authored by Cristian Simarro's avatar Cristian Simarro

get exe and args from /proc/self/cmdline

parent 55960ccf
...@@ -1063,9 +1063,31 @@ static void darshan_get_exe_and_mounts(struct darshan_core_runtime *core, ...@@ -1063,9 +1063,31 @@ static void darshan_get_exe_and_mounts(struct darshan_core_runtime *core,
*/ */
if(argc == 0) if(argc == 0)
{ {
strncat(core->log_exemnt_p, __progname_full, space_left); /* get the name of the executable and the arguments from
space_left = DARSHAN_EXE_LEN-strlen(core->log_exemnt_p); /proc/self/cmdline */
strncat(core->log_exemnt_p, " <unknown args>", space_left); FILE *fh;
int i, ii;
char cmdl[DARSHAN_EXE_LEN];
cmdl[0] = '\0';
fh = fopen("/proc/self/cmdline","r");
if(fh) {
ii = 0;
fgets(cmdl,DARSHAN_EXE_LEN,fh);
for(i=1;i<DARSHAN_EXE_LEN;i++) {
if(cmdl[i]==0 && ii == 0) {
cmdl[i]=' '; ii = 1;
} else if(cmdl[i]==0 && ii == 1) {
break;
} else {
ii = 0;
}
}
} else {
sprintf(cmdl, " <unknown args>");
}
fclose(fh);
strncat(core->log_exemnt_p, cmdl, space_left);
space_left = DARSHAN_EXE_LEN-strlen(core->log_exemnt_p); space_left = DARSHAN_EXE_LEN-strlen(core->log_exemnt_p);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment