Browse Source

Clifford Wolf:


			
			
				rocklinux
			
			
		
Clifford Wolf 19 years ago
parent
commit
3decce2161
2 changed files with 29 additions and 20 deletions
  1. +14
    -10
      misc/tools-source/fl_wrapper.c
  2. +15
    -10
      misc/tools-source/fl_wrapper.c.sh

+ 14
- 10
misc/tools-source/fl_wrapper.c

@ -865,24 +865,27 @@ static int pid2ppid(int pid)
static char *getpname(int pid)
{
static char p[512];
char buffer[100]="";
char buffer[513]="";
char *arg=0, *b;
int i, fd, rc;
sprintf(buffer, "/proc/%d/cmdline", pid);
if ( (fd = open(buffer, O_RDONLY, 0)) < 0 ) return "unkown";
if ( (rc = read(fd, buffer, 99)) > 0) {
if ( (rc = read(fd, buffer, 512)) > 0) {
buffer[rc--] = 0;
for (i=0; i<rc; i++)
if (!buffer[i]) { arg = buffer+i+1; break; }
if (buffer[i] == 0 && buffer[i+1] != '-')
{ arg = buffer+i+1; break; }
}
close(fd);
b = basename(buffer);
snprintf(p, 512, "%s", b);
if ( !strcmp(b, "bash") || !strcmp(b, "sh") || !strcmp(b, "perl") )
if (arg && *arg && *arg != '-')
if ( !strcmp(b, "bash") || !strcmp(b, "sh") ||
!strcmp(b, "perl") || !strcmp(b, "python") )
if (arg && *arg && strlen(arg) < 100 &&
!strchr(arg, ' ') && !strchr(arg, ';'))
snprintf(p, 512, "%s(%s)", b, basename(arg));
return p;
@ -901,11 +904,12 @@ static void addptree(int *txtpos, char *cmdtxt, int pid, int basepid)
p = getpname(pid);
if ( strcmp(l, p) )
*txtpos += snprintf(cmdtxt+*txtpos, 4096-*txtpos, "%s%s",
*txtpos ? "." : "", getpname(pid));
else
*txtpos += snprintf(cmdtxt+*txtpos, 4096-*txtpos, "*");
if (*txtpos < 4000)
if ( strcmp(l, p) )
*txtpos += snprintf(cmdtxt+*txtpos, 4096-*txtpos, "%s%s",
*txtpos ? "." : "", getpname(pid));
else
*txtpos += snprintf(cmdtxt+*txtpos, 4096-*txtpos, "*");
strcpy(l, p);
}

+ 15
- 10
misc/tools-source/fl_wrapper.c.sh

@ -233,24 +233,28 @@ static int pid2ppid(int pid)
static char *getpname(int pid)
{
static char p[512];
char buffer[100]="";
char buffer[513]="";
char *arg=0, *b;
int i, fd, rc;
sprintf(buffer, "/proc/%d/cmdline", pid);
if ( (fd = open(buffer, O_RDONLY, 0)) < 0 ) return "unkown";
if ( (rc = read(fd, buffer, 99)) > 0) {
if ( (rc = read(fd, buffer, 512)) > 0) {
buffer[rc--] = 0;
for (i=0; i<rc; i++)
if (!buffer[i]) { arg = buffer+i+1; break; }
if (buffer[i] == 0 && buffer[i+1] != '-')
{ arg = buffer+i+1; break; }
}
close(fd);
b = basename(buffer);
snprintf(p, 512, "%s", b);
if ( !strcmp(b, "bash") || !strcmp(b, "sh") || !strcmp(b, "perl") )
if (arg && *arg && *arg != '-')
if ( !strcmp(b, "bash") || !strcmp(b, "sh") ||
!strcmp(b, "perl") || !strcmp(b, "python") )
if ( arg && *arg &&
strlen(arg) < 100 && !strchr(arg, '\n') &&
!strchr(arg, ' ') && !strchr(arg, ';') )
snprintf(p, 512, "%s(%s)", b, basename(arg));
return p;
@ -269,11 +273,12 @@ static void addptree(int *txtpos, char *cmdtxt, int pid, int basepid)
p = getpname(pid);
if ( strcmp(l, p) )
*txtpos += snprintf(cmdtxt+*txtpos, 4096-*txtpos, "%s%s",
*txtpos ? "." : "", getpname(pid));
else
*txtpos += snprintf(cmdtxt+*txtpos, 4096-*txtpos, "*");
if (*txtpos < 4000)
if ( strcmp(l, p) )
*txtpos += snprintf(cmdtxt+*txtpos, 4096-*txtpos, "%s%s",
*txtpos ? "." : "", getpname(pid));
else
*txtpos += snprintf(cmdtxt+*txtpos, 4096-*txtpos, "*");
strcpy(l, p);
}

Loading…
Cancel
Save