Ticket #1824: arg0-fix.patch
File arg0-fix.patch, 2.7 KB (added by , 16 years ago) |
---|
-
src/system/libroot/os/image.c
33 33 34 34 if (invoker[0]) { 35 35 status = __parse_invoke_line(invoker, &newArgs, 36 (char * const **)&args, &argCount );36 (char * const **)&args, &argCount, args[1]); 37 37 if (status < B_OK) 38 38 return status; 39 39 } … … 146 146 147 147 status_t 148 148 __parse_invoke_line(char *invoker, char ***_newArgs, 149 char * const **_oldArgs, int32 *_argCount )149 char * const **_oldArgs, int32 *_argCount, const char *arg0) 150 150 { 151 151 int32 i, count = 0; 152 152 char *arg = invoker; … … 166 166 // copy invoker and old arguments and to newArgs 167 167 168 168 for (i = 0; (arg = next_argument(&invoker, true)) != NULL; i++) { 169 169 newArgs[i] = arg; 170 170 } 171 171 for (i = 0; i < *_argCount; i++) { 172 newArgs[i + count] = (char *)(*_oldArgs)[i]; 172 if (i == 0) 173 newArgs[i + count] = arg0; 174 else 175 newArgs[i + count] = (char *)(*_oldArgs)[i]; 173 176 } 174 177 175 178 newArgs[i + count] = NULL; -
src/system/libroot/posix/unistd/exec.c
72 72 73 73 // test validity of executable + support for scripts 74 74 { 75 status_t status = __test_executable( args[0], invoker);75 status_t status = __test_executable(path, invoker); 76 76 if (status < B_OK) { 77 77 errno = status; 78 78 return -1; 79 79 } 80 80 81 81 if (invoker[0]) { 82 status = __parse_invoke_line(invoker, &newArgs, &args, &argCount );82 status = __parse_invoke_line(invoker, &newArgs, &args, &argCount, path); 83 83 if (status < B_OK) { 84 84 errno = status; 85 85 return -1; … … 94 94 // don't care and pass everything to the kernel - it will have to 95 95 // do the right thing :) 96 96 97 errno = _kern_exec(path, argCount, args, envCount, environment);97 errno = _kern_exec(path, argCount, newArgs ? newArgs : args, envCount, environment); 98 98 // if this call returns, something definitely went wrong 99 99 100 100 free(newArgs); -
headers/private/libroot/libroot_private.h
22 22 #endif 23 23 24 24 status_t __parse_invoke_line(char *invoker, char ***_newArgs, 25 char * const **_oldArgs, int32 *_argCount );25 char * const **_oldArgs, int32 *_argCount, const char *arg0); 26 26 status_t __get_next_image_dependency(image_id id, uint32 *cookie, 27 27 const char **_name); 28 28 status_t __test_executable(const char *path, char *invoker);