Commit 45c766b9 authored by Shane Snyder's avatar Shane Snyder

Merge branch 'master' into 'master'

Get Fortran executable arguments

We usually work with Fortran programs and it is always useful to have the arguments of the executable in the Darshan log. This feature allows Drshan to get the executable name and the arguments from /proc/self/cmdline if the program is Fortran (argc==0)

See merge request !3
parents 55960ccf 16217667
......@@ -1024,7 +1024,9 @@ static void darshan_get_exe_and_mounts(struct darshan_core_runtime *core,
char* truncate_string = "<TRUNCATED>";
int truncate_offset;
int space_left = DARSHAN_EXE_LEN;
int i;
FILE *fh;
int i, ii;
char cmdl[DARSHAN_EXE_LEN];
int tmp_index = 0;
int skip = 0;
......@@ -1063,9 +1065,28 @@ static void darshan_get_exe_and_mounts(struct darshan_core_runtime *core,
*/
if(argc == 0)
{
strncat(core->log_exemnt_p, __progname_full, space_left);
space_left = DARSHAN_EXE_LEN-strlen(core->log_exemnt_p);
strncat(core->log_exemnt_p, " <unknown args>", space_left);
/* get the name of the executable and the arguments from
/proc/self/cmdline */
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;
}
}
fclose(fh);
} else {
sprintf(cmdl, "%s <unknown args>", __progname_full);
}
strncat(core->log_exemnt_p, cmdl, space_left);
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