aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2019-01-08 15:51:04 +0000
committerRon Yorston <rmy@pobox.com>2019-01-08 15:51:04 +0000
commitbade8b3460ea3cf1182cd1bda9faf8b6ccee6a25 (patch)
tree6b0c855e3d0688e07f512e61d17d76d09c64c6cb /libbb
parent59701e7f6a483d4aad4dc7088c673cd69fe294c8 (diff)
downloadbusybox-w32-bade8b3460ea3cf1182cd1bda9faf8b6ccee6a25.tar.gz
busybox-w32-bade8b3460ea3cf1182cd1bda9faf8b6ccee6a25.tar.bz2
busybox-w32-bade8b3460ea3cf1182cd1bda9faf8b6ccee6a25.zip
ps: add support for the args column
Implement read_cmdline() for WIN32 by storing the command line in the same way as the applet name. The applet name is actually used for the comm column which is truncated to COMM_LEN. Using this as the size of the bb_comm array avoids the need to calculate MAX_APPLET_NAME_LEN.
Diffstat (limited to 'libbb')
-rw-r--r--libbb/appletlib.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index ba52ef581..b3a144aee 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -1067,30 +1067,37 @@ 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
1070char bb_applet_name[MAX_APPLET_NAME_LEN+1]; 1070char bb_comm[COMM_LEN];
1071char bb_command_line[128];
1071# endif 1072# endif
1072 1073
1073void FAST_FUNC run_applet_no_and_exit(int applet_no, const char *name, char **argv) 1074void FAST_FUNC run_applet_no_and_exit(int applet_no, const char *name, char **argv)
1074{ 1075{
1075 int argc = string_array_len(argv); 1076 int argc = string_array_len(argv);
1077# if ENABLE_PLATFORM_MINGW32
1078 int i;
1079 const char *vmask;
1080 unsigned int mask;
1081# endif
1076 1082
1077 /* 1083 /*
1078 * We do not use argv[0]: do not want to repeat massaging of 1084 * We do not use argv[0]: do not want to repeat massaging of
1079 * "-/sbin/halt" -> "halt", for example. 1085 * "-/sbin/halt" -> "halt", for example.
1080 */ 1086 */
1081 applet_name = name; 1087 applet_name = name;
1082#if ENABLE_PLATFORM_MINGW32 1088# if ENABLE_PLATFORM_MINGW32
1083 strcpy(bb_applet_name, applet_name); 1089 safe_strncpy(bb_comm, applet_name, sizeof(bb_comm));
1084
1085 {
1086 const char *vmask;
1087 unsigned int mask;
1088 1090
1089 vmask = getenv("BB_UMASK"); 1091 safe_strncpy(bb_command_line, applet_name, sizeof(bb_command_line));
1090 if (vmask && sscanf(vmask, "%o", &mask) == 1) 1092 for (i=1; i < argc && argv[i] &&
1091 umask((mode_t)(mask&0777)); 1093 strlen(bb_command_line) + strlen(argv[i]) + 2 < 128; ++i) {
1094 strcat(strcat(bb_command_line, " "), argv[i]);
1092 } 1095 }
1093#endif 1096
1097 vmask = getenv("BB_UMASK");
1098 if (vmask && sscanf(vmask, "%o", &mask) == 1)
1099 umask((mode_t)(mask&0777));
1100# endif
1094 1101
1095 /* Special case. POSIX says "test --help" 1102 /* Special case. POSIX says "test --help"
1096 * should be no different from e.g. "test --foo". 1103 * should be no different from e.g. "test --foo".