From 1a73ba100105e84b2c0106ee187b6e7466189539 Mon Sep 17 00:00:00 2001 From: turbocat Date: Wed, 3 Mar 2021 21:14:44 +0000 Subject: [PATCH] SHELL: - Added new API: SC_GET_PID - Fixed data type pid - unsigned int. - Fixed cmd_ps output pid; git-svn-id: svn://kolibrios.org@8633 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/system/shell/cmd/cmd_ps.c | 6 +++--- .../shell/modules/module_program_console.c | 18 +++++++++++++----- programs/system/shell/program_console.h | 1 + 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/programs/system/shell/cmd/cmd_ps.c b/programs/system/shell/cmd/cmd_ps.c index b07290ddb..ce09f0e4d 100644 --- a/programs/system/shell/cmd/cmd_ps.c +++ b/programs/system/shell/cmd/cmd_ps.c @@ -18,13 +18,13 @@ printf (" PID NAME RAM KB\n\r", PID, buf1k+10); for (i = 1;;i++) { n = kol_process_info(i, buf1k); - PID = *(buf1k+30); - STATE = *(buf1k+50); + memcpy(&PID, buf1k+30 ,sizeof(unsigned)); + STATE = *(buf1k+50); if (9 != STATE) { if (!sel || 0 == strnicmp(param, buf1k+10, 10)) { - printf (" %7d %11s %d\n\r", PID, buf1k+10, (*(int*)(buf1k+26)+1)/1024); + printf (" %7u %11s %d\n\r", PID, buf1k+10, (*(int*)(buf1k+26)+1)/1024); if (sel) { LAST_PID = PID; diff --git a/programs/system/shell/modules/module_program_console.c b/programs/system/shell/modules/module_program_console.c index 957c5a8a4..57c5602db 100644 --- a/programs/system/shell/modules/module_program_console.c +++ b/programs/system/shell/modules/module_program_console.c @@ -7,6 +7,7 @@ int program_console(int pid) char name[32]; char *buffer; +char *buf1k; int result; int i; char command; @@ -17,7 +18,7 @@ itoa(pid, name); strcat(name, "-SHELL"); buffer = NULL; - +buf1k = NULL; for (i = 0; i < 30; i++) { @@ -41,7 +42,6 @@ for (i = 0; i < 30; i++) switch (command) { - case SC_EXIT: *buffer = SC_OK; is_end = 1; @@ -64,8 +64,8 @@ for (i = 0; i < 30; i++) case SC_PUTS: printf("%s", buffer+1 ); *buffer = SC_OK; - break; - + break; + case SC_GETC: *(buffer+1) = (char) getch() ; *buffer = SC_OK; @@ -75,7 +75,15 @@ for (i = 0; i < 30; i++) gets(buffer+1, size-2); *buffer = SC_OK; break; - + + case SC_GET_PID: + buf1k=malloc(1024); + kol_process_info(-1, buf1k); + memcpy(buffer+1, buf1k+30, sizeof(unsigned)); + *buffer = SC_OK; + free(buf1k); + break; + default: #if LANG_ENG printf (" Error in console application.\n\r"); diff --git a/programs/system/shell/program_console.h b/programs/system/shell/program_console.h index 84973855a..880cfe7f4 100644 --- a/programs/system/shell/program_console.h +++ b/programs/system/shell/program_console.h @@ -6,3 +6,4 @@ #define SC_GETC 4 #define SC_GETS 5 #define SC_CLS 6 +#define SC_GET_PID 7