From 99584b3fb0952693d15ed4f344d53bed9cb3c434 Mon Sep 17 00:00:00 2001 From: Daniel Tartavel Date: Wed, 6 May 2020 16:56:53 +0200 Subject: [PATCH] debug --- main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 3fd553f..2ab1953 100644 --- a/main.c +++ b/main.c @@ -66,6 +66,7 @@ int getprocinfo( int ppid, char cmdline[], char cmd[], char user[] ) int pid = ppid; int level = 0; int retval = 0; + char * pos; while ( flag == 0) { @@ -121,10 +122,9 @@ int getprocinfo( int ppid, char cmdline[], char cmd[], char user[] ) perror(child_path); return 5; } - fscanf( fh1, "%s", str); - pch = strtok( str, "=\0" ); - pch = strtok( NULL , "=\0" ); - sprintf( user, "%s", pch); + fgets( str, 1024, fh1); + pos = strstr( str, "USER=") + 5; + sprintf( user, "%s", pos); fclose(fh1); return retval; }