This commit is contained in:
Jan Schär 2022-03-31 10:24:28 +02:00
parent 9750a752c3
commit 042a4187ed
4 changed files with 9 additions and 9 deletions

View File

@ -63,7 +63,7 @@ struct spawninfo {
struct aos_rpc_server rpc_server; struct aos_rpc_server rpc_server;
}; };
struct spawninfo *sawn_get_process_list(void); struct spawninfo *spawn_get_process_list(void);
// parse a commandline into arguments // parse a commandline into arguments
void spawn_parse_cmd(char *cmdline, int *argc, char **argv); void spawn_parse_cmd(char *cmdline, int *argc, char **argv);

View File

@ -189,7 +189,7 @@ aos_rpc_process_get_name(struct aos_rpc *rpc, domainid_t pid, char **name) {
*name = malloc(name_len); *name = malloc(name_len);
if (*name == NULL) return LIB_ERR_MALLOC_FAIL; if (*name == NULL) return LIB_ERR_MALLOC_FAIL;
memcpy(*name, rpc->shared_mem, name_len); memcpy(*name, rpc->shared_mem, name_len);
assert((*name)[name_len] == '\0'); assert(name_len != 0 && (*name)[name_len - 1] == '\0');
return err; return err;
} }

View File

@ -211,7 +211,7 @@ static errval_t handle_rpc_process_get_name(
// search for the pid // search for the pid
char *name = NULL; char *name = NULL;
for (struct spawninfo *si = sawn_get_process_list(); si != NULL; si = si->next) { for (struct spawninfo *si = spawn_get_process_list(); si != NULL; si = si->next) {
if (si->pid == pid) { if (si->pid == pid) {
name = si->binary_name; name = si->binary_name;
break; break;
@ -245,7 +245,7 @@ static errval_t handle_rpc_process_get_all_pids(
domainid_t *buf = rpc->shared_mem; domainid_t *buf = rpc->shared_mem;
// get all PIDs that fit into the given space // get all PIDs that fit into the given space
for (struct spawninfo *si = sawn_get_process_list(); si != NULL; si = si->next) { for (struct spawninfo *si = spawn_get_process_list(); si != NULL; si = si->next) {
if (list_size + sizeof(domainid_t) > RPC_SHARED_SIZE) { if (list_size + sizeof(domainid_t) > RPC_SHARED_SIZE) {
return AOS_ERR_RPC_RET_TOO_BIG; return AOS_ERR_RPC_RET_TOO_BIG;
} }

View File

@ -20,7 +20,7 @@ struct spawninfo *spawn_process_list = NULL;
// TODO: handle "freeing" of PIDs in case we learn how to detect stopped child processes // TODO: handle "freeing" of PIDs in case we learn how to detect stopped child processes
domainid_t spawn_last_pid = 1; domainid_t spawn_last_pid = 1;
struct spawninfo *sawn_get_process_list(void) { struct spawninfo *spawn_get_process_list(void) {
return spawn_process_list; return spawn_process_list;
} }
@ -337,7 +337,7 @@ errval_t spawn_load_argv(int argc, char *argv[], struct spawninfo *si,
// - Initialize the spawn_info struct // - Initialize the spawn_info struct
// TODO // TODO
// copy name to spawninfo struct // copy name to spawninfo struct
size_t binary_name_len = strlen(argv[0]); size_t binary_name_len = strlen(argv[0]) + 1;
si->binary_name = malloc(binary_name_len); si->binary_name = malloc(binary_name_len);
if (si->binary_name == NULL) { if (si->binary_name == NULL) {
return LIB_ERR_MALLOC_FAIL; return LIB_ERR_MALLOC_FAIL;