1
0
This commit is contained in:
Daniel Tartavel 2020-05-06 17:14:36 +02:00
parent f5b5cdb275
commit 57e0fbaf58

38
main.c
View File

@ -20,6 +20,28 @@ int isinarray( int pid, int array[], int n )
return 0;
}
int null2space( char str[] )
{
int flag =0;
int x = 0;
while ( flag == 0 )
{
if ( (int) str[x] == 0 )
{
if ( (int) str[x+1] != 0 )
{
str[x] = ' ';
}else
{
flag = 1;
}
}
x++;
}
return x-1 ;
}
int getpids(int pid, int exploded[])
{
FILE *fh;
@ -92,20 +114,7 @@ int getprocinfo( int ppid, char cmdline[], char cmd[], char user[] )
}
fgets( str, 1024, fh1);
flag = 0;
while ( flag == 0 )
{
if ( (int) str[x] == 0 )
{
if ( (int) str[x+1] != 0 )
{
str[x] = ' ';
}else
{
flag = 1;
}
}
x++;
}
null2space( str );
sprintf(cmdline, "%s", str);
fclose(fh1);
sprintf( child_path, "/proc/%d/comm", pid );
@ -123,6 +132,7 @@ int getprocinfo( int ppid, char cmdline[], char cmd[], char user[] )
return 5;
}
fgets( str, 1024, fh1);
null2space( str );
pos = strstr( str, "USER=");
sprintf( user, "%s", pos+5);
fclose(fh1);