aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2019-01-08 15:57:03 +0000
committerRon Yorston <rmy@pobox.com>2019-01-08 16:01:43 +0000
commit3476fb9f4c369b0f99bef7175aa4084ba771ebd7 (patch)
tree3c37c3dbf87c99a00f8540d4a55ba9cf2029bba1 /libbb
parentbade8b3460ea3cf1182cd1bda9faf8b6ccee6a25 (diff)
downloadbusybox-w32-3476fb9f4c369b0f99bef7175aa4084ba771ebd7.tar.gz
busybox-w32-3476fb9f4c369b0f99bef7175aa4084ba771ebd7.tar.bz2
busybox-w32-3476fb9f4c369b0f99bef7175aa4084ba771ebd7.zip
ps: display interpreted script name in comm column
When an interpreted script is being run the comm column in ps should display the name of the script not the name of the interpreter. Use a fake applet pathname to indicate which argument contains the script. This also allows pidof to obtain the pid of a script.
Diffstat (limited to 'libbb')
-rw-r--r--libbb/appletlib.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index b3a144aee..3ff2b5dc6 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -1067,6 +1067,7 @@ int busybox_main(int argc UNUSED_PARAM, char **argv)
1067# if NUM_APPLETS > 0 1067# if NUM_APPLETS > 0
1068 1068
1069# if ENABLE_PLATFORM_MINGW32 1069# if ENABLE_PLATFORM_MINGW32
1070static int interp = 0;
1070char bb_comm[COMM_LEN]; 1071char bb_comm[COMM_LEN];
1071char bb_command_line[128]; 1072char bb_command_line[128];
1072# endif 1073# endif
@@ -1086,7 +1087,9 @@ void FAST_FUNC run_applet_no_and_exit(int applet_no, const char *name, char **ar
1086 */ 1087 */
1087 applet_name = name; 1088 applet_name = name;
1088# if ENABLE_PLATFORM_MINGW32 1089# if ENABLE_PLATFORM_MINGW32
1089 safe_strncpy(bb_comm, applet_name, sizeof(bb_comm)); 1090 safe_strncpy(bb_comm,
1091 interp ? bb_basename(argv[interp]) : applet_name,
1092 sizeof(bb_comm));
1090 1093
1091 safe_strncpy(bb_command_line, applet_name, sizeof(bb_command_line)); 1094 safe_strncpy(bb_command_line, applet_name, sizeof(bb_command_line));
1092 for (i=1; i < argc && argv[i] && 1095 for (i=1; i < argc && argv[i] &&
@@ -1206,6 +1209,19 @@ int main(int argc UNUSED_PARAM, char **argv)
1206 argv[0][0] &= 0x7f; 1209 argv[0][0] &= 0x7f;
1207 } 1210 }
1208#endif 1211#endif
1212#if ENABLE_PLATFORM_MINGW32
1213 /* detect if we're running an interpreted script */
1214 if (argv[0][1] == ':' && argv[0][2] == '/') {
1215 switch (argv[0][0]) {
1216 case '1':
1217 interp = 1;
1218 break;
1219 case'2':
1220 interp = 2;
1221 break;
1222 }
1223 }
1224#endif
1209 1225
1210#if defined(__MINGW64_VERSION_MAJOR) 1226#if defined(__MINGW64_VERSION_MAJOR)
1211 if ( stdin ) { 1227 if ( stdin ) {